[Patch, avr] Fix PR 13697 without KEEPing .data
Georg-Johann Lay
avr@gjlay.de
Wed Jul 2 18:00:00 GMT 2014
Senthil Kumar Selvaraj schrieb:
> The fix for PR 13697
> (https://sourceware.org/bugzilla/show_bug.cgi?id=13697) added a
> KEEP(*(.data)) to prevent the .bss section from getting an incorrect
> VMA.
>
> The patch fixes the problem, but it also prevents the linker
> from gc'ing .data sections. It also only keeps sections named
> .data, so -fdata-sections could potentially cause the fix to break
> (it works right now because the assembler generates an empty .data section).
>
> The following patch fixes the problem by explicitly setting the
> .bss section's VMA to the end of .data's VMA. It kinda looks redundant,
> as both .data and .bss are assigned to the same region, but is needed because
> the region's ORIGIN is hardcoded whereas the start of .data/.bss varies
> by device (and is passed along as -Tdata=<address> by the compiler
> driver).
>
> Does this look ok? I verified that the testcase mentioned in the
> bug report works fine.
Can you explain how it works? Just by mentioning ADDR(.data)?
BTW, if you are polishing the linker script, you could also take care of
some missing .gnu.linkonce sections? At least .t, .r and .b are missing.
Johann
> ld/ChangeLog
>
> 2014-07-02 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
>
> * scripttempl/avr.sc: Remove KEEP for .data and
> force .bss VMA to end of .data VMA.
>
> diff --git ld/scripttempl/avr.sc ld/scripttempl/avr.sc
> index 10714e1..d356b71 100644
> --- ld/scripttempl/avr.sc
> +++ ld/scripttempl/avr.sc
> @@ -166,10 +166,7 @@ SECTIONS
> .data ${RELOCATING-0} :
> {
> ${RELOCATING+ PROVIDE (__data_start = .) ; }
> - /* --gc-sections will delete empty .data. This leads to wrong start
> - addresses for subsequent sections because -Tdata= from the command
> - line will have no effect, see PR13697. Thus, keep .data */
> - KEEP (*(.data))
> + *(.data)
> ${RELOCATING+ *(.data*)}
> *(.rodata) /* We need to include .rodata here if gcc is used */
> ${RELOCATING+ *(.rodata*)} /* with -fdata-sections. */
> @@ -179,7 +176,7 @@ SECTIONS
> ${RELOCATING+ PROVIDE (__data_end = .) ; }
> } ${RELOCATING+ > data ${RELOCATING+AT> text}}
>
> - .bss ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
> + .bss ${RELOCATING+ ADDR(.data) + SIZEOF (.data)} ${RELOCATING-0} :${RELOCATING+ AT (ADDR (.bss))}
> {
> ${RELOCATING+ PROVIDE (__bss_start = .) ; }
> *(.bss)
>
More information about the Binutils
mailing list