This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch,AVR]: Fix PR13697: Wrong symbols with --gc-sections

This bug is because an empty .data will be removed by the ld machinery.

However, .bss and other following sections get their placement after
.data, and if .data is removed and the default section start of .data
is used, the following sections start at a wrong place. Typically,
they start in some I/O location instead of at RAM start.

The start of .data is not encoded for each device in binutils.
Instead, the compiler passes -Tdata= per linker SPEC in order to
inform binutils where RAM starts.

The patch just adds KEEP for .data.

Lightly tested with a small example.

If the patch is approved, please also install is and
maybe also backport to 2.22.


    PR 13697
    * scripttempl/ (.data): Keep it.
diff --git a/ld/scripttempl/ b/ld/scripttempl/
index c11de86..a1aecc8 100644
--- a/ld/scripttempl/
+++ b/ld/scripttempl/
@@ -162,6 +162,10 @@ SECTIONS
     ${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))
     *(.rodata)  /* We need to include .rodata here if gcc is used */
     *(.rodata*) /* with -fdata-sections.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]