diff options
Diffstat (limited to 'ld/scripttempl')
-rw-r--r-- | ld/scripttempl/avr.sc | 40 | ||||
-rw-r--r-- | ld/scripttempl/pe.sc | 29 | ||||
-rw-r--r-- | ld/scripttempl/pep.sc | 31 |
3 files changed, 79 insertions, 21 deletions
diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc index 8479ec3..a902385 100644 --- a/ld/scripttempl/avr.sc +++ b/ld/scripttempl/avr.sc @@ -186,14 +186,21 @@ SECTIONS /* Internal text space or external memory. */ .text ${RELOCATING-0} : { - ${RELOCATING+*(.vectors) +EOF +test -z "${RELOCATING}" || cat <<EOF + *(.vectors) KEEP(*(.vectors)) - /* For data that needs to reside in the lower 64k of progmem. */ - *(.progmem.gcc*) + /* For data that needs to reside in the lower 64k of progmem. + For data accessed with ELPM use .progmemx.* instead + so that no lower 64k .progmem addresses are wasted. */ + __progmem_start = . ; + *(.progmem) + *(.progmem.*) + __progmem_end = . ; + ASSERT (__progmem_start == __progmem_end || __progmem_end <= 0x10000, + ".progmem section exceeds 0x10000"); - /* PR 13812: Placing the trampolines here gives a better chance - that they will be in range of the code that uses them. */ . = ALIGN(2); __trampolines_start = . ; /* The jump trampolines for the 16-bit limited relocs will reside here. */ @@ -201,18 +208,13 @@ SECTIONS *(.trampolines*) __trampolines_end = . ; - /* avr-libc expects these data to reside in lower 64K. */ - *libprintf_flt.a:*(.progmem.data) - *libc.a:*(.progmem.data) - - *(.progmem.*) - . = ALIGN(2); /* For code that needs to reside in the lower 128k progmem. */ *(.lowtext) - *(.lowtext*)} - + *(.lowtext*) +EOF +cat <<EOF ${CONSTRUCTING+ __ctors_start = . ; } ${CONSTRUCTING+ *(.ctors) } ${CONSTRUCTING+ __ctors_end = . ; } @@ -273,6 +275,7 @@ SECTIONS *(.hightext) *(.hightext*) + *(.progmemx) *(.progmemx.*) . = ALIGN(2); @@ -365,21 +368,20 @@ EOF fi if test -n "${HAVE_FLMAP}"; then - cat <<EOF - -${RELOCATING+ +test -z "${RELOCATING}" || cat <<EOF __flmap_init_label = DEFINED(__flmap_init_start) ? __flmap_init_start : 0 ; /* User can specify position of .rodata in flash (LMA) by supplying __RODATA_FLASH_START__ or __flmap, where the former takes precedence. */ __RODATA_FLASH_START__ = DEFINED(__RODATA_FLASH_START__) ? __RODATA_FLASH_START__ : DEFINED(__flmap) ? __flmap * 32K : ${RODATA_FLASH_START}; -ASSERT (__RODATA_FLASH_START__ % 32K == 0, \"__RODATA_FLASH_START__ must be a multiple of 32 KiB\") +ASSERT (__RODATA_FLASH_START__ % 32K == 0, "__RODATA_FLASH_START__ must be a multiple of 32 KiB") __flmap = ${FLMAP_MASK} & (__RODATA_FLASH_START__ >> 15); __RODATA_FLASH_START__ = __flmap << 15; __rodata_load_start = MAX (__data_load_end, __RODATA_FLASH_START__); -__rodata_start = __RODATA_ORIGIN__ + __rodata_load_start - __RODATA_FLASH_START__;} - +__rodata_start = __RODATA_ORIGIN__ + __rodata_load_start - __RODATA_FLASH_START__; +EOF +cat << EOF .rodata ${RELOCATING+ __rodata_start} ${RELOCATING-0} : ${RELOCATING+ AT (__rodata_load_start)} { *(.rodata) diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc index 96a4751..8fb98b2 100644 --- a/ld/scripttempl/pe.sc +++ b/ld/scripttempl/pe.sc @@ -14,7 +14,7 @@ fi # substitution, so we do this instead. # Sorting of the .foo$* sections is required by the definition of # grouped sections in PE. -# Sorting of the file names in R_IDATA is required by the +# Sorting of the file names in R_IDATA and R_DIDAT is required by the # current implementation of dlltool (this could probably be changed to # use grouped sections instead). if test "${RELOCATING}"; then @@ -39,6 +39,18 @@ if test "${RELOCATING}"; then R_IDATA67=' KEEP (SORT(*)(.idata$6)) KEEP (SORT(*)(.idata$7))' + R_DIDAT234=' + __DELAY_IMPORT_DIRECTORY_start__ = .; + KEEP (SORT(*)(.didat$2)) + KEEP (SORT(*)(.didat$3)) + __DELAY_IMPORT_DIRECTORY_end__ = .; + /* These zeroes mark the end of the import list. */ + . += (__DELAY_IMPORT_DIRECTORY_end__ - __DELAY_IMPORT_DIRECTORY_start__) ? 8*4 : 0; + KEEP (SORT(*)(.didat$4))' + R_DIDAT5='KEEP (SORT(*)(.didat$5))' + R_DIDAT67=' + KEEP (SORT(*)(.didat$6)) + KEEP (SORT(*)(.didat$7))' R_CRT_XC='KEEP (*(SORT(.CRT$XC*))) /* C initialization */' R_CRT_XI='KEEP (*(SORT(.CRT$XI*))) /* C++ initialization */' R_CRT_XL='KEEP (*(SORT(.CRT$XL*))) /* TLS callbacks */' @@ -61,6 +73,9 @@ else R_IDATA234= R_IDATA5= R_IDATA67= + R_DIDAT234= + R_DIDAT5= + R_DIDAT67= R_CRT_XC= R_CRT_XI= R_CRT_XL= @@ -131,6 +146,11 @@ SECTIONS ${RELOCATING+__rt_psrelocs_start = .;} ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))} ${RELOCATING+__rt_psrelocs_end = .;} + /* read-only parts of .didat */ + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_DIDAT234} + ${R_DIDAT67} /* .ctors & .dtors */ ${CONSTRUCTING+ @@ -244,6 +264,13 @@ SECTIONS ${R_IDATA67} } + .didat ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${R_DIDAT5} + } + /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be at the end of section. This is important because _tls_start MUST be at the beginning of the section to enable SECREL32 relocations with TLS diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc index e2c6c2c..841ee35 100644 --- a/ld/scripttempl/pep.sc +++ b/ld/scripttempl/pep.sc @@ -14,7 +14,7 @@ fi # substitution, so we do this instead. # Sorting of the .foo$* sections is required by the definition of # grouped sections in PE. -# Sorting of the file names in R_IDATA is required by the +# Sorting of the file names in R_IDATA and R_DIDAT is required by the # current implementation of dlltool (this could probably be changed to # use grouped sections instead). if test "${RELOCATING}"; then @@ -40,6 +40,19 @@ if test "${RELOCATING}"; then R_IDATA67=' KEEP (SORT(*)(.idata$6)) KEEP (SORT(*)(.idata$7))' + R_DIDAT234=' + __DELAY_IMPORT_DIRECTORY_start__ = .; + KEEP (SORT(*)(.didat$2)) + KEEP (SORT(*)(.didat$3)) + __DELAY_IMPORT_DIRECTORY_end__ = .; + /* These zeroes mark the end of the import list. */ + . += (__DELAY_IMPORT_DIRECTORY_end__ - __DELAY_IMPORT_DIRECTORY_start__) ? 8*4 : 0; + . = ALIGN(8); + KEEP (SORT(*)(.didat$4))' + R_DIDAT5='SORT(*)(.didat$5)' + R_DIDAT67=' + KEEP (SORT(*)(.didat$6)) + KEEP (SORT(*)(.didat$7))' R_CRT_XC='KEEP (*(SORT(.CRT$XC*))) /* C initialization */' R_CRT_XI='KEEP (*(SORT(.CRT$XI*))) /* C++ initialization */' R_CRT_XL='KEEP (*(SORT(.CRT$XL*))) /* TLS callbacks */' @@ -62,6 +75,9 @@ else R_IDATA234= R_IDATA5= R_IDATA67= + R_DIDAT234= + R_DIDAT5= + R_DIDAT67= R_CRT_XC= R_CRT_XI= R_CRT_XL= @@ -132,6 +148,12 @@ SECTIONS ${RELOCATING+__rt_psrelocs_start = .;} ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))} ${RELOCATING+__rt_psrelocs_end = .;} + /* read-only parts of .didat */ + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + ${RELOCATING+. = ALIGN(8);} + ${R_DIDAT234} + ${R_DIDAT67} /* .ctors & .dtors */ ${CONSTRUCTING+. = ALIGN(8);} @@ -251,6 +273,13 @@ SECTIONS ${R_IDATA67} } + .didat ${RELOCATING+BLOCK(__section_alignment__)} : + { + /* This cannot currently be handled with grouped sections. + See pep.em:sort_sections. */ + ${R_DIDAT5} + } + /* Windows TLS expects .tls\$AAA to be at the start and .tls\$ZZZ to be at the end of the .tls section. This is important because _tls_start MUST be at the beginning of the section to enable SECREL32 relocations with TLS |