bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/19161] New: GNU ld wrongly garbage collects section referenced v


From: xinliangli at gmail dot com
Subject: [Bug ld/19161] New: GNU ld wrongly garbage collects section referenced via __start_SECTIONNAME
Date: Wed, 21 Oct 2015 23:07:18 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19161

            Bug ID: 19161
           Summary: GNU ld wrongly garbage collects section referenced via
                    __start_SECTIONNAME
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: xinliangli at gmail dot com
  Target Milestone: ---

Here is a small reproducible:

// Failed with gnu ld

gcc -fuse-ld=bfd  -fdata-sections -Wl,--gc-sections gctest.c gctest2.c

/tmp/cc4jxArE.o: In function `dump':
gctest2.c:(.text+0xc): undefined reference to `__start_my_section'
collect2: error: ld returned 1 exit status


// Fine with Gold:

gcc -fuse-ld=gold -fdata-sections -Wl,--gc-sections gctest.c gctest2.c




// gctest.c

extern int variable;
int main()
{
  return variable;
}


// gctest2.c

typedef struct A {
   int i;
   int j;
} A;

extern int printf(const char*,...);
extern int atexit(void (*)(void));
A __attribute__((section("my_section"))) a[2] = {{1,2}, {3,4}};

extern A __start_my_section;
extern A __stop_my_section;

int variable = 0;


void dump()
{
   A* ap = &__start_my_section;
   printf("%d %d\n", ap->i, ap->j);
}

void __attribute__((constructor)) foo() {
   atexit(dump);
}

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