Bug 28385 - gold: linker script symbol assignment given wrong visibility with versioning script
Summary: gold: linker script symbol assignment given wrong visibility with versioning ...
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.37
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-24 22:56 UTC by Mike Frysinger
Modified: 2021-09-24 23:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2021-09-24 22:56:36 UTC
the attr package uses a linker script to set up compatibility symbols, and a versioning script to set up the visibility.  bfd handles this, but gold sets the wrong visibility.

in the test below you can see bfd puts symtest_o@SYM_1.0 in the exported dynsym but gold does not.

$ cat test.c
void symtest_new() {}
void symtest_old() {}

$ cat test.lds 
"symtest_o@SYM_1.0" = symtest_old;

$ cat test.ver
SYM_1.0 {
global: symtest_o;
local: *;
};
SYM_1.1 {
global: symtest_new;
};

$ gcc -fPIC -shared test.c -Wl,--version-script=test.ver -Wl,test.lds -o libtest.so -fuse-ld=bfd
$ readelf -sW libtest.so | grep -i sym
Symbol table '.dynsym' contains 9 entries:
     5: 0000000000001100     0 FUNC    GLOBAL DEFAULT   11 symtest_o@SYM_1.0
     6: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.0
     7: 00000000000010f9     7 FUNC    GLOBAL DEFAULT   11 symtest_new@@SYM_1.1
     8: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.1
Symbol table '.symtab' contains 19 entries:
     6: 0000000000001100     7 FUNC    LOCAL  DEFAULT   11 symtest_old
    11: 0000000000001100     0 FUNC    GLOBAL DEFAULT   11 symtest_o@SYM_1.0
    13: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.0
    15: 00000000000010f9     7 FUNC    GLOBAL DEFAULT   11 symtest_new
    16: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.1

$ gcc -fPIC -shared test.c -Wl,--version-script=test.ver -Wl,test.lds -o libtest.so -fuse-ld=gold
$ readelf -sW libtest.so | grep symtest
Symbol table '.dynsym' contains 8 entries:
     5: 00000000000005e9     7 FUNC    GLOBAL DEFAULT   12 symtest_new@@SYM_1.1
     6: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.0
     7: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.1
Symbol table '.symtab' contains 20 entries:
     5: 00000000000005f0     7 FUNC    LOCAL  DEFAULT   12 symtest_old
     8: 00000000000005f0     0 FUNC    LOCAL  DEFAULT   12 symtest_o@SYM_1.0
    13: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.1
    14: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS SYM_1.0
    15: 00000000000005e9     7 FUNC    GLOBAL DEFAULT   12 symtest_new