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

Submitted by:  Timothy Housel <wileypob>
Submitted on:  Mon 04 Nov 2002 10:50:28 PM UTC  
Category: binutilsSeverity: 1,5
Item Group: sw-bugStatus: Fixed
Privacy: PublicAssigned to: Stephane Carrez <ciceron>
Open/Closed: Closed

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

Fixed in release 2.1

Stephane Carrez <ciceron>
Project AdministratorIn charge of this item.
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>
Project Member


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


CC list is empty


Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.


Please enter the title of George Orwell's famous dystopian book (it's a date):



Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 14 Nov 2002 10:21:18 PM UTCciceronStatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)

Back to the top

Powered by Savane 3.1-cleanup1