WIP MachO binutils port assisted by AI I may consider upstreaming this in the future.
0

Configure Feed

Select the types of activity you want to include in your feed.

ld: Change indirect symbol from IR to undefined

bfd/

PR ld/28264
* elflink.c (_bfd_elf_merge_symbol): Change indirect symbol from
IR to undefined.

ld/

PR ld/28264
* testsuite/ld-plugin/lto.exp: Run PR ld/28264 test.
* testsuite/ld-plugin/pr28264-1.d: New file.
* testsuite/ld-plugin/pr28264-2.d: Likewise.
* testsuite/ld-plugin/pr28264-3.d: Likewise.
* testsuite/ld-plugin/pr28264-4.d: Likewise.
* testsuite/ld-plugin/pr28264.c: Likewise.
* testsuite/ld-plugin/pr28264.ver: Likewise.

H.J. Lu (Aug 27, 2021, 7:44 PM -0700) 7de7786b b05929a2

+63 -6
+17 -6
bfd/elflink.c
··· 1272 1272 olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0; 1273 1273 } 1274 1274 1275 - /* Handle a case where plugin_notice won't be called and thus won't 1276 - set the non_ir_ref flags on the first pass over symbols. */ 1277 1275 if (oldbfd != NULL 1278 - && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN) 1279 - && newdyn != olddyn) 1276 + && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)) 1280 1277 { 1281 - h->root.non_ir_ref_dynamic = true; 1282 - hi->root.non_ir_ref_dynamic = true; 1278 + if (newdyn != olddyn) 1279 + { 1280 + /* Handle a case where plugin_notice won't be called and thus 1281 + won't set the non_ir_ref flags on the first pass over 1282 + symbols. */ 1283 + h->root.non_ir_ref_dynamic = true; 1284 + hi->root.non_ir_ref_dynamic = true; 1285 + } 1286 + 1287 + if ((oldbfd->flags & BFD_PLUGIN) != 0 1288 + && hi->root.type == bfd_link_hash_indirect) 1289 + { 1290 + /* Change indirect symbol from IR to undefined. */ 1291 + hi->root.type = bfd_link_hash_undefined; 1292 + hi->root.u.undef.abfd = oldbfd; 1293 + } 1283 1294 } 1284 1295 1285 1296 /* NEWDEF and OLDDEF indicate whether the new or old symbol,
+9
ld/testsuite/ld-plugin/lto.exp
··· 238 238 "-flto -fno-common $lto_no_fat" \ 239 239 {pr25355.c} \ 240 240 [list [list "nm" "$plug_opt" "pr25355.d"]]] \ 241 + [list "pr28264.so" \ 242 + "-shared -Wl,--version-script=pr28264.ver" \ 243 + "-flto $lto_no_fat -fPIC" \ 244 + {pr28264.c} \ 245 + {{readelf {--dyn-syms --wide} pr28264-1.d} \ 246 + {readelf {--dyn-syms --wide} pr28264-2.d} \ 247 + {readelf {--dyn-syms --wide} pr28264-3.d} \ 248 + {readelf {--dyn-syms --wide} pr28264-4.d}} \ 249 + {pr28264.so}] \ 241 250 ]] 242 251 } 243 252
+5
ld/testsuite/ld-plugin/pr28264-1.d
··· 1 + Symbol table '\.dynsym' contains [0-9]+ entries: 2 + +Num: +Value +Size Type +Bind +Vis +Ndx Name 3 + #... 4 + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?foo@VERSION.1 5 + #pass
+5
ld/testsuite/ld-plugin/pr28264-2.d
··· 1 + Symbol table '\.dynsym' contains [0-9]+ entries: 2 + +Num: +Value +Size Type +Bind +Vis +Ndx Name 3 + #... 4 + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?bar@@VERSION.1 5 + #pass
+4
ld/testsuite/ld-plugin/pr28264-3.d
··· 1 + #failif 2 + #... 3 + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?foo 4 + #...
+4
ld/testsuite/ld-plugin/pr28264-4.d
··· 1 + #failif 2 + #... 3 + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT .*[0-9]+ _?bar 4 + #...
+11
ld/testsuite/ld-plugin/pr28264.c
··· 1 + void 2 + __attribute__ ((symver ("foo@VERSION.1"))) 3 + foo (void) 4 + { 5 + } 6 + 7 + void 8 + __attribute__ ((symver ("bar@@VERSION.1"))) 9 + bar1 (void) 10 + { 11 + }
+8
ld/testsuite/ld-plugin/pr28264.ver
··· 1 + VERSION.1 2 + { 3 + global: 4 + foo; 5 + bar; 6 + local: 7 + *; 8 + };