This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Patch,AVR]: Fix PR13697: Wrong symbols with --gc-sections
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: binutils at sourceware dot org
- Cc: Denis Chertykov <chertykov at gmail dot com>, Marek Michalkiewicz <marekm at amelek dot gda dot pl>, Eric Weddington <eric dot weddington at atmel dot com>
- Date: Mon, 28 May 2012 11:49:49 +0200
- Subject: [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.
Johann
ld/
PR 13697
* scripttempl/avr.sc (.data): Keep it.
diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc
index c11de86..a1aecc8 100644
--- a/ld/scripttempl/avr.sc
+++ b/ld/scripttempl/avr.sc
@@ -162,6 +162,10 @@ SECTIONS
{
${RELOCATING+ PROVIDE (__data_start = .) ; }
*(.data)
+ /* --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*)
*(.rodata) /* We need to include .rodata here if gcc is used */
*(.rodata*) /* with -fdata-sections. */