GNU Binutils with patches for OS216
修订版 | 8a1285a1a3048f77abc56be3ff2f83a782506a04 (tree) |
---|---|
时间 | 2019-05-17 23:38:14 |
作者 | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
PR24567, assertion failure in ldlang.c:6868 when compiling with -flto
As the existing comment said: "a common ought to be overridden by a
def in a -flto object". This patch makes the code actually do that,
rather than allowing a normal object file common to override a -flto
defined symbol.
PR 24567
* plugin.c (plugin_notice): Do not let a common symbol override
a non-common definition in IR.
(cherry picked from commit af4fa23fba220c1b26bb3c8a7996b406dcc181cc)
@@ -1,3 +1,9 @@ | ||
1 | +2019-05-17 Alan Modra <amodra@gmail.com> | |
2 | + | |
3 | + PR 24567 | |
4 | + * plugin.c (plugin_notice): Do not let a common symbol override | |
5 | + a non-common definition in IR. | |
6 | + | |
1 | 7 | 2019-04-24 H.J. Lu <hongjiu.lu@intel.com> |
2 | 8 | |
3 | 9 | PR ld/24458 |
@@ -1316,30 +1316,36 @@ plugin_notice (struct bfd_link_info *info, | ||
1316 | 1316 | ref = TRUE; |
1317 | 1317 | } |
1318 | 1318 | |
1319 | - /* Otherwise, it must be a new def. */ | |
1320 | - else | |
1319 | + | |
1320 | + /* A common symbol should be merged with other commons or | |
1321 | + defs with the same name. In particular, a common ought | |
1322 | + to be overridden by a def in a -flto object. In that | |
1323 | + sense a common is also a ref. */ | |
1324 | + else if (bfd_is_com_section (section)) | |
1321 | 1325 | { |
1322 | - /* Ensure any symbol defined in an IR dummy BFD takes on a | |
1323 | - new value from a real BFD. Weak symbols are not normally | |
1324 | - overridden by a new weak definition, and strong symbols | |
1325 | - will normally cause multiple definition errors. Avoid | |
1326 | - this by making the symbol appear to be undefined. */ | |
1327 | - if (((h->type == bfd_link_hash_defweak | |
1328 | - || h->type == bfd_link_hash_defined) | |
1329 | - && is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner)) | |
1330 | - || (h->type == bfd_link_hash_common | |
1331 | - && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner))) | |
1326 | + if (h->type == bfd_link_hash_common | |
1327 | + && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner)) | |
1332 | 1328 | { |
1333 | 1329 | h->type = bfd_link_hash_undefweak; |
1334 | 1330 | h->u.undef.abfd = sym_bfd; |
1335 | 1331 | } |
1332 | + ref = TRUE; | |
1333 | + } | |
1336 | 1334 | |
1337 | - /* A common symbol should be merged with other commons or | |
1338 | - defs with the same name. In particular, a common ought | |
1339 | - to be overridden by a def in a -flto object. In that | |
1340 | - sense a common is also a ref. */ | |
1341 | - if (bfd_is_com_section (section)) | |
1342 | - ref = TRUE; | |
1335 | + /* Otherwise, it must be a new def. | |
1336 | + Ensure any symbol defined in an IR dummy BFD takes on a | |
1337 | + new value from a real BFD. Weak symbols are not normally | |
1338 | + overridden by a new weak definition, and strong symbols | |
1339 | + will normally cause multiple definition errors. Avoid | |
1340 | + this by making the symbol appear to be undefined. */ | |
1341 | + else if (((h->type == bfd_link_hash_defweak | |
1342 | + || h->type == bfd_link_hash_defined) | |
1343 | + && is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner)) | |
1344 | + || (h->type == bfd_link_hash_common | |
1345 | + && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner))) | |
1346 | + { | |
1347 | + h->type = bfd_link_hash_undefweak; | |
1348 | + h->u.undef.abfd = sym_bfd; | |
1343 | 1349 | } |
1344 | 1350 | |
1345 | 1351 | if (ref) |