1

this is my problem: I have created a linker script that divides my code in different regions. That's the linker script:

OUTPUT_ARCH(arm)

SECTIONS {

. = 0x400000;
.stack1 : {
    __stack_start1 = . ;
}

. = 0x800000;
.stack2 : {
    __stack_start2 = . ;
}

. = 0x19900000;
.vectors1 : {
    *(.resetvector1)
}

. = 0x19900018;
.irq_vector : {
    *(.irqvector)
}

. = 0x19908000;
.init : {           /* Init code and data   */
    *(.text1.init)
    *(.text2.init)
}

/DISCARD/ : {           /* Exit code and data   */
    *(.text.exit)
    *(.data.exit)
    *(.exitcall.exit)
}

.text : {           /* Real text segment    */
    _text = .;      /* Text and read-only data*/
        *(.text)
    _etext = .;     /* End of text section  */
}

. = ALIGN(8192);

.data : {
    /*
     * first, the init task union, aligned
     * to an 8192 byte boundary.
     */
    *(.init.task)

    /*
     * then the cacheline aligned data
     */
    . = ALIGN(32);
    *(.data.cacheline_aligned)

    /*
     * and the usual data section
     */
    *(.data)
    CONSTRUCTORS

    _edata = .;
}

.bss : {
    __bss_start = .;    /* BSS  */
    *(.bss)
    *(COMMON)
    _end = . ;
}

. = ALIGN(8192);
_end_kernel = . ;

.vectors2 : {
        *(.resetvector2)
}

}

it works fine but the output file is about 450Mb when the whole program is about few kb!! WHY?? I think that ld fills (with 0x0) the empty regions between my stack, data, text etc areas. How to avoid this problem?

Thanks in advance.

Lore
  • 53
  • 5

1 Answers1

1

I'd try using the .sectionname location syntax instead of . = location .section. And if this does not help, defining separate memory regions with MEMORY and making sections go there should definitely stop this behavior.

dbrank0
  • 9,026
  • 2
  • 37
  • 55