[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/14162] New: avr-ld misplaces .bss if --gc-sections is given and

From: max at suse dot de
Subject: [Bug ld/14162] New: avr-ld misplaces .bss if --gc-sections is given and .data is empty
Date: Thu, 24 May 2012 16:32:04 +0000


             Bug #: 14162
           Summary: avr-ld misplaces .bss if --gc-sections is given and
                    .data is empty
           Product: binutils
           Version: 2.22
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: address@hidden
        ReportedBy: address@hidden
    Classification: Unclassified

When linking a program for an AVR model that has a different RAM start address
than the default set in the linker script for the respective AVR family, gcc
calls ld with -Tdata=<address> to override the default and ld automatically
puts the .bss section behind .data in the RAM.

Now if a program is linked that has no .data and gcc is called with
-Wl,--gc-sections, the address giveb to -Tdata gets lost and .bss gets placed
at the default location, which lies in the middle of the I/O regisrer space for
models that need a value that is different from the default.

This is a regression from version 2.19.1.

Consider the following example:
$ cat check.c 
int x;
main() { x++; }

$ avr-gcc -v -mmcu=atmega328p -Wl,--gc-sections -o check check.c
Using built-in specs.
Target: avr
Configured with: ../gcc-4.3.3/configure -v --target=avr --disable-nls
--mandir=/opt/cross/avr/share/man --infodir=/opt/cross/avr/share/info
--prefix=/opt/cross/avr --with-gnu-ld --with-gnu-as --enable-languages=c,c++
--disable-libssp --with-dwarf2
Thread model: single
gcc version 4.3.3 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mmcu=atmega328p' '-o' 'check'
 /opt/cross/avr/libexec/gcc/avr/4.3.3/cc1 -quiet -v -imultilib avr5 check.c
-quiet -dumpbase check.c -mmcu=atmega328p -auxbase check -version -o
ignoring nonexistent directory
#include "..." search starts here:
#include <...> search starts here:
End of search list.
GNU C (GCC) version 4.3.3 (avr)
        compiled by GNU C version 4.6.2, GMP version 5.0.2, MPFR version 3.0.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 01ae89caa829da89431e8cde9ed97070
COLLECT_GCC_OPTIONS='-v' '-mmcu=atmega328p' '-o' 'check'
 /opt/cross/avr/lib/gcc/avr/4.3.3/../../../../avr/bin/as -v -mmcu=atmega328p -o
/tmp/ccWlIAJR.o /tmp/ccceMgwU.s
GNU assembler version 2.22 (avr) using BFD version (GNU Binutils) 2.22
COLLECT_GCC_OPTIONS='-v' '-mmcu=atmega328p' '-o' 'check'
 /opt/cross/avr/lib/gcc/avr/4.3.3/../../../../avr/bin/ld -m avr5 -Tdata
0x800100 -o check
-L/opt/cross/avr/lib/gcc/avr/4.3.3/../../../../avr/lib --gc-sections
/tmp/ccWlIAJR.o -lgcc -lc -lgcc

$ avr-objdump -h check

check:     file format elf32-avr

Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000000d0  00000000  00000000  00000074  2**1
  1 .bss          00000002  00800060  00800060  00000144  2**0
  2 .stab         000006cc  00000000  00000000  00000144  2**2
  3 .stabstr      00000054  00000000  00000000  00000810  2**0

.bss has been located at address 0x800060, which is the default for avr5,
although ld has been called with -Tdata 0x800100, which would be the correct
value for the ATmega328p device.

If either .data is non-empty, or --gc-sections is left out, or version 2.19.1
is used, .bss gets placed at the correct location.

Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]