bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/18954] New: LTO drops weak binding with "ld -r"


From: hjl.tools at gmail dot com
Subject: [Bug ld/18954] New: LTO drops weak binding with "ld -r"
Date: Fri, 11 Sep 2015 16:14:05 +0000

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

            Bug ID: 18954
           Summary: LTO drops weak binding with "ld -r"
           Product: binutils
           Version: 2.26 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

address@hidden lto]$ cat test.c
extern int x;

void foobar (void) { x--; }
address@hidden lto]$ cat test-weak.c
#include <stdio.h>

int x;

__attribute__((weak))
void foobar (void) { x++; }

int main (void)
{
  foobar ();
  if (x == -1)
    printf ("OK\n");
  return 0;
}
address@hidden lto]$ make
gcc  -flto -O2    -c -o test-weak.o test-weak.c
gcc  -flto -O2  -nostdlib -r -o test-intermediate.o test-weak.o
readelf -sW test-intermediate.o | grep foobar
    10: 0000000000000000     8 FUNC    GLOBAL DEFAULT    1 foobar
gcc  -flto -O2    -c -o test.o test.c
gcc  -flto -O2  test-intermediate.o test.o -o prog
test.o (symbol from plugin): In function `foobar':
(.text+0x0): multiple definition of `foobar'
test-intermediate.o:(.text+0x0): first defined here
/tmp/cciS2u59.ltrans0.ltrans.o: In function `foobar':
<artificial>:(.text+0x0): multiple definition of `foobar'
test-intermediate.o:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'prog' failed
make: *** [prog] Error 1
address@hidden lto]$

Linker shouldn't set LDPR_PREVAILING_DEF_IRONLY on a weakdef
for relocatable output.

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