bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/13697] New: [avr ] Wrong symbol values with --gc-sections


From: gjl at gcc dot gnu.org
Subject: [Bug ld/13697] New: [avr ] Wrong symbol values with --gc-sections
Date: Thu, 16 Feb 2012 10:18:16 +0000

http://sourceware.org/bugzilla/show_bug.cgi?id=13697

             Bug #: 13697
           Summary: [avr ] Wrong symbol values with --gc-sections
           Product: binutils
           Version: 2.23 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: address@hidden
        ReportedBy: address@hidden
    Classification: Unclassified


Suppose the following small C program:

int main (void)
{
    extern char __heap_start;
    return (int) & __heap_start;
}

Compile with:

avr-gcc heap-start.c -mmcu=atmega168 -o heal-start.elf -Os -save-temps
-Wl,-Map,heap-start.map -Wl,--gc-sections

Assembler output is:


    .file    "heap-start.c"
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__SREG__ = 0x3f
__tmp_reg__ = 0
__zero_reg__ = 1
    .section    .text.startup,"ax",@progbits
.global    main
    .type    main, @function
main:
.L__stack_usage = 0
    ldi r24,lo8(__heap_start)
    ldi r25,hi8(__heap_start)
    ret
    .size    main, .-main
    .ident    "GCC: (GNU) 4.7.0 20120206 (experimental)"


ATmega168 has RAM start at 0x100 but the generated map file reads

...
 *(.data)
 *(.data*)
 *(.rodata)
 *(.rodata*)
 *(.gnu.linkonce.d*)
                0x00800100                . = ALIGN (0x2)
                0x00800100                _edata = .
                0x00800100                PROVIDE (__data_end, .)

.bss            0x00800060        0x0
                0x00800060                PROVIDE (__bss_start, .)
 *(.bss)
 *(.bss*)
 *(COMMON)
                0x00800060                PROVIDE (__bss_end, .)
                0x0000008a                __data_load_start = LOADADDR (.data)
                0x0000008a                __data_load_end = (__data_load_start
+ SIZEOF (.data))

.noinit         0x00800060        0x0
                0x00800060                PROVIDE (__noinit_start, .)
 *(.noinit*)
                0x00800060                PROVIDE (__noinit_end, .)
                0x00800060                _end = .
                0x00800060                PROVIDE (__heap_start, .)
...

That is obviously wrong because .bss starts at RAM 0x60.

Notice that the program does not define data in the static storage.
If data in static storage is added or --gc-sectons is removed, the values are
as expected.

-- 
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]