bugGNU Development Chain for 68HC11/68HC12 - Bugs: bug #1612, linker garbage collection removes...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #1612: linker garbage collection removes static initialization

Submitter:  Timothy Housel <wileypob>
Submitted:  Mon 04 Nov 2002 10:50:28 PM UTC
   
 
Category:  binutils Severity:  1,5
Item Group:  sw-bug Status:  Fixed
Privacy:  Public Assigned to:  ciceron
Open/Closed:  Closed

Thu 14 Nov 2002 10:21:18 PM UTC, comment #1: 

Fixed in release 2.1

Stephane Carrez <ciceron>
Group administrator
Mon 04 Nov 2002 10:50:28 PM UTC, original submission:  

The functions in the .ctors section, which should get called during runtime initialization, are being removed when using linker garbage collection.

I compiled using the 2.0 release with the following options:

$ m6812-elf-gcc -v
Reading specs from /cygdrive/c/m6812-elf-tools/lib/gcc-lib/m6812-elf/3.0.4/specs

Configured with: ./configure --target=m6812-elf --program-prefix=m6812-elf- --prefix=/cygdrive/c/m6812-elf-tools --exec-prefix=/cygdrive/c/m6812-elf-tools --enable-languages=c,c++
Thread model: single
gcc version 3.0.4 m68hc1x-20020922

$ m6812-elf-gcc -m68hc12 -mshort -mauto-incdec -msoft-reg-count=0 -Wall -ggdb -Os -mrelax -finline -ffixed-z -fomit-frame-pointer -fno-rtti -fno-exceptions -fshort-enums -ffunction-sections -c foo.cpp

and I link with:
$ m6812-elf-gcc -m68hc12 -mshort -mauto-incdec -msoft-reg-count=0 -Wl,-T,m68hc12elfb.x -Wl,-N -Wl,-M -Wl,--gc-sections -Wl,--cref -Wl,-m,m68hc12elfb -o foo.elf

As an example, I created foo.cpp:
---------------------------------------------------
static int foo(void);
int foo(void)
{
    volatile int baz = 0x42;
    return baz;
}

int bar = foo();
---------------------------------------------------

When compiled with -Wl,--gc-sections, bar is not initialized. When I remove -Wl,--gc-sections, bar is correctly initialized to 0x42.

Timothy Housel <wileypob>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2002-11-14 ciceron StatusNone None
    Open/ClosedOpen None

Back to the top

Powered by Savane 3.13-4448.
Corresponding source code