GNU Binutils with patches for OS216
リビジョン | c20c30f615756ddfccc4bb75c65ccfc1a399466e (tree) |
---|---|
日時 | 2018-02-07 02:17:39 |
作者 | Eric Botcazou <ebotcazou@gcc....> |
コミッター | Eric Botcazou |
Fix PR ld/22263 on SPARC.
This is -fpie -pie generating dynamic relocations in the text section,
simply because no TLS transitions are applied in PIE mode. The meat
of the patch is to turn calls to bfd_link_pic (info) in TLS-related code
into !bfd_link_executable (info) and there are quite a lot of them...
bfd/
* elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic
into call to !bfd_link_executable and tidy up.
(_bfd_sparc_elf_check_relocs): Fix formatting and tidy up.
<R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_IE_HI22>: Likewise.
<GOT relocations>: Remove useless code, tidy and merge blocks.
<R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_WPLT30>: Tidy up.
(_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call
to !bfd_link_executable.
(allocate_dynrelocs): Likewise.
(_bfd_sparc_elf_relocate_section): Fix formatting and tidy up.
<R_SPARC_TLS_GD_HI22>: Merge into...
<R_SPARC_TLS_GD_LO10>: ...this. Adjust 4th argument in call to
sparc_elf_tls_transition and remove redundant code.
<R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to
!bfd_link_executable.
<R_SPARC_TLS_LDO_HIX22>: Likewise.
<R_SPARC_TLS_LE_HIX22>: Likewise. Tidy up.
<R_SPARC_TLS_LDM_CALL>: Likewise.
<R_SPARC_TLS_GD_CALL>: Likewise. Tidy up.
<R_SPARC_TLS_GD_ADD>: Likewise.
<R_SPARC_TLS_LDM_ADD>: Likewise.
<R_SPARC_TLS_LDO_ADD>: Likewise.
<R_SPARC_TLS_IE_LD>: Likewise.
ld/
* testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC.
(pr22263-1): Pass AFLAGS_PIC to the assembler.
* testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie32.dd: Adjust to above.
* testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions.
* testsuite/ld-sparc/tlspie64.dd: Adjust to above.
@@ -1,3 +1,34 @@ | ||
1 | +2018-02-06 Eric Botcazou <ebotcazou@adacore.com> | |
2 | + | |
3 | + PR ld/22263 | |
4 | + * elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic | |
5 | + into call to !bfd_link_executable and tidy up. | |
6 | + (_bfd_sparc_elf_check_relocs): Fix formatting and tidy up. | |
7 | + <R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to | |
8 | + !bfd_link_executable. | |
9 | + <R_SPARC_TLS_IE_HI22>: Likewise. | |
10 | + <GOT relocations>: Remove useless code, tidy and merge related blocks. | |
11 | + <R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to | |
12 | + !bfd_link_executable. | |
13 | + <R_SPARC_WPLT30>: Tidy up. | |
14 | + (_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call to | |
15 | + !bfd_link_executable. | |
16 | + (allocate_dynrelocs): Likewise. | |
17 | + (_bfd_sparc_elf_relocate_section): Fix formatting and tidy up. | |
18 | + <R_SPARC_TLS_GD_HI22>: Merge into... | |
19 | + <R_SPARC_TLS_GD_LO10>: ...this. Adjust 4th argument in call to | |
20 | + sparc_elf_tls_transition and remove redundant code. | |
21 | + <R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to | |
22 | + !bfd_link_executable. | |
23 | + <R_SPARC_TLS_LDO_HIX22>: Likewise. | |
24 | + <R_SPARC_TLS_LE_HIX22>: Likewise. Tidy up. | |
25 | + <R_SPARC_TLS_LDM_CALL>: Likewise. | |
26 | + <R_SPARC_TLS_GD_CALL>: Likewise. Tidy up. | |
27 | + <R_SPARC_TLS_GD_ADD>: Likewise. | |
28 | + <R_SPARC_TLS_LDM_ADD>: Likewise. | |
29 | + <R_SPARC_TLS_LDO_ADD>: Likewise. | |
30 | + <R_SPARC_TLS_IE_LD>: Likewise. | |
31 | + | |
1 | 32 | 2018-02-06 Miloš Stojanović <milos.stojanovic@rt-rk.com> |
2 | 33 | |
3 | 34 | PR 22789 |
@@ -1331,33 +1331,25 @@ sparc_elf_tls_transition (struct bfd_link_info *info, bfd *abfd, | ||
1331 | 1331 | if (! ABI_64_P (abfd) |
1332 | 1332 | && r_type == R_SPARC_TLS_GD_HI22 |
1333 | 1333 | && ! _bfd_sparc_elf_tdata (abfd)->has_tlsgd) |
1334 | - r_type = R_SPARC_REV32; | |
1334 | + return R_SPARC_REV32; | |
1335 | 1335 | |
1336 | - if (bfd_link_pic (info)) | |
1336 | + if (!bfd_link_executable (info)) | |
1337 | 1337 | return r_type; |
1338 | 1338 | |
1339 | 1339 | switch (r_type) |
1340 | 1340 | { |
1341 | 1341 | case R_SPARC_TLS_GD_HI22: |
1342 | - if (is_local) | |
1343 | - return R_SPARC_TLS_LE_HIX22; | |
1344 | - return R_SPARC_TLS_IE_HI22; | |
1342 | + return is_local ? R_SPARC_TLS_LE_HIX22 : R_SPARC_TLS_IE_HI22; | |
1345 | 1343 | case R_SPARC_TLS_GD_LO10: |
1346 | - if (is_local) | |
1347 | - return R_SPARC_TLS_LE_LOX10; | |
1348 | - return R_SPARC_TLS_IE_LO10; | |
1349 | - case R_SPARC_TLS_IE_HI22: | |
1350 | - if (is_local) | |
1351 | - return R_SPARC_TLS_LE_HIX22; | |
1352 | - return r_type; | |
1353 | - case R_SPARC_TLS_IE_LO10: | |
1354 | - if (is_local) | |
1355 | - return R_SPARC_TLS_LE_LOX10; | |
1356 | - return r_type; | |
1344 | + return is_local ? R_SPARC_TLS_LE_LOX10 : R_SPARC_TLS_IE_LO10; | |
1357 | 1345 | case R_SPARC_TLS_LDM_HI22: |
1358 | 1346 | return R_SPARC_TLS_LE_HIX22; |
1359 | 1347 | case R_SPARC_TLS_LDM_LO10: |
1360 | 1348 | return R_SPARC_TLS_LE_LOX10; |
1349 | + case R_SPARC_TLS_IE_HI22: | |
1350 | + return is_local ? R_SPARC_TLS_LE_HIX22 : r_type; | |
1351 | + case R_SPARC_TLS_IE_LO10: | |
1352 | + return is_local ? R_SPARC_TLS_LE_LOX10 : r_type; | |
1361 | 1353 | } |
1362 | 1354 | |
1363 | 1355 | return r_type; |
@@ -1425,16 +1417,14 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1425 | 1417 | if (r_symndx < symtab_hdr->sh_info) |
1426 | 1418 | { |
1427 | 1419 | /* A local symbol. */ |
1428 | - isym = bfd_sym_from_r_symndx (&htab->sym_cache, | |
1429 | - abfd, r_symndx); | |
1420 | + isym = bfd_sym_from_r_symndx (&htab->sym_cache, abfd, r_symndx); | |
1430 | 1421 | if (isym == NULL) |
1431 | 1422 | return FALSE; |
1432 | 1423 | |
1433 | 1424 | /* Check relocation against local STT_GNU_IFUNC symbol. */ |
1434 | 1425 | if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) |
1435 | 1426 | { |
1436 | - h = elf_sparc_get_local_sym_hash (htab, abfd, rel, | |
1437 | - TRUE); | |
1427 | + h = elf_sparc_get_local_sym_hash (htab, abfd, rel, TRUE); | |
1438 | 1428 | if (h == NULL) |
1439 | 1429 | return FALSE; |
1440 | 1430 |
@@ -1456,13 +1446,10 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1456 | 1446 | h = (struct elf_link_hash_entry *) h->root.u.i.link; |
1457 | 1447 | } |
1458 | 1448 | |
1459 | - if (h && h->type == STT_GNU_IFUNC) | |
1449 | + if (h && h->type == STT_GNU_IFUNC && h->def_regular) | |
1460 | 1450 | { |
1461 | - if (h->def_regular) | |
1462 | - { | |
1463 | - h->ref_regular = 1; | |
1464 | - h->plt.refcount += 1; | |
1465 | - } | |
1451 | + h->ref_regular = 1; | |
1452 | + h->plt.refcount += 1; | |
1466 | 1453 | } |
1467 | 1454 | |
1468 | 1455 | /* Compatibility with old R_SPARC_REV32 reloc conflicting |
@@ -1505,13 +1492,13 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1505 | 1492 | |
1506 | 1493 | case R_SPARC_TLS_LE_HIX22: |
1507 | 1494 | case R_SPARC_TLS_LE_LOX10: |
1508 | - if (bfd_link_pic (info)) | |
1495 | + if (!bfd_link_executable (info)) | |
1509 | 1496 | goto r_sparc_plt32; |
1510 | 1497 | break; |
1511 | 1498 | |
1512 | 1499 | case R_SPARC_TLS_IE_HI22: |
1513 | 1500 | case R_SPARC_TLS_IE_LO10: |
1514 | - if (bfd_link_pic (info)) | |
1501 | + if (!bfd_link_executable (info)) | |
1515 | 1502 | info->flags |= DF_STATIC_TLS; |
1516 | 1503 | /* Fall through */ |
1517 | 1504 |
@@ -1530,14 +1517,6 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1530 | 1517 | |
1531 | 1518 | switch (r_type) |
1532 | 1519 | { |
1533 | - default: | |
1534 | - case R_SPARC_GOT10: | |
1535 | - case R_SPARC_GOT13: | |
1536 | - case R_SPARC_GOT22: | |
1537 | - case R_SPARC_GOTDATA_OP_HIX22: | |
1538 | - case R_SPARC_GOTDATA_OP_LOX10: | |
1539 | - tls_type = GOT_NORMAL; | |
1540 | - break; | |
1541 | 1520 | case R_SPARC_TLS_GD_HI22: |
1542 | 1521 | case R_SPARC_TLS_GD_LO10: |
1543 | 1522 | tls_type = GOT_TLS_GD; |
@@ -1546,6 +1525,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1546 | 1525 | case R_SPARC_TLS_IE_LO10: |
1547 | 1526 | tls_type = GOT_TLS_IE; |
1548 | 1527 | break; |
1528 | + default: | |
1529 | + tls_type = GOT_NORMAL; | |
1530 | + break; | |
1549 | 1531 | } |
1550 | 1532 | |
1551 | 1533 | if (h != NULL) |
@@ -1573,26 +1555,23 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1573 | 1555 | _bfd_sparc_elf_local_got_tls_type (abfd) |
1574 | 1556 | = (char *) (local_got_refcounts + symtab_hdr->sh_info); |
1575 | 1557 | } |
1576 | - switch (r_type) | |
1577 | - { | |
1578 | - case R_SPARC_GOTDATA_OP_HIX22: | |
1579 | - case R_SPARC_GOTDATA_OP_LOX10: | |
1580 | - break; | |
1581 | 1558 | |
1582 | - default: | |
1583 | - local_got_refcounts[r_symndx] += 1; | |
1584 | - break; | |
1585 | - } | |
1559 | + if (r_type != R_SPARC_GOTDATA_OP_HIX22 | |
1560 | + && r_type != R_SPARC_GOTDATA_OP_LOX10) | |
1561 | + local_got_refcounts[r_symndx] += 1; | |
1562 | + | |
1586 | 1563 | old_tls_type = _bfd_sparc_elf_local_got_tls_type (abfd) [r_symndx]; |
1587 | 1564 | } |
1588 | 1565 | |
1589 | - /* If a TLS symbol is accessed using IE at least once, | |
1590 | - there is no point to use dynamic model for it. */ | |
1591 | - if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN | |
1592 | - && (old_tls_type != GOT_TLS_GD | |
1593 | - || tls_type != GOT_TLS_IE)) | |
1566 | + /* If a TLS symbol is accessed using IE at least once, there is no point | |
1567 | + in using the dynamic model for it. */ | |
1568 | + if (old_tls_type != tls_type) | |
1594 | 1569 | { |
1595 | - if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD) | |
1570 | + if (old_tls_type == GOT_UNKNOWN) | |
1571 | + ; | |
1572 | + else if (old_tls_type == GOT_TLS_GD && tls_type == GOT_TLS_IE) | |
1573 | + ; | |
1574 | + else if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD) | |
1596 | 1575 | tls_type = old_tls_type; |
1597 | 1576 | else |
1598 | 1577 | { |
@@ -1602,10 +1581,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1602 | 1581 | abfd, h ? h->root.root.string : "<local>"); |
1603 | 1582 | return FALSE; |
1604 | 1583 | } |
1605 | - } | |
1606 | 1584 | |
1607 | - if (old_tls_type != tls_type) | |
1608 | - { | |
1609 | 1585 | if (h != NULL) |
1610 | 1586 | _bfd_sparc_elf_hash_entry (h)->tls_type = tls_type; |
1611 | 1587 | else |
@@ -1613,11 +1589,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1613 | 1589 | } |
1614 | 1590 | } |
1615 | 1591 | |
1616 | - if (htab->elf.sgot == NULL) | |
1617 | - { | |
1618 | - if (!_bfd_elf_create_got_section (htab->elf.dynobj, info)) | |
1619 | - return FALSE; | |
1620 | - } | |
1592 | + if (!htab->elf.sgot | |
1593 | + && !_bfd_elf_create_got_section (htab->elf.dynobj, info)) | |
1594 | + return FALSE; | |
1621 | 1595 | |
1622 | 1596 | if (eh != NULL) |
1623 | 1597 | eh->has_got_reloc = 1; |
@@ -1625,28 +1599,25 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1625 | 1599 | |
1626 | 1600 | case R_SPARC_TLS_GD_CALL: |
1627 | 1601 | case R_SPARC_TLS_LDM_CALL: |
1628 | - if (bfd_link_pic (info)) | |
1629 | - { | |
1630 | - /* These are basically R_SPARC_TLS_WPLT30 relocs against | |
1631 | - __tls_get_addr. */ | |
1632 | - h = (struct elf_link_hash_entry *) | |
1633 | - bfd_link_hash_lookup (info->hash, "__tls_get_addr", TRUE, | |
1634 | - FALSE, TRUE); | |
1635 | - } | |
1636 | - else | |
1602 | + if (bfd_link_executable (info)) | |
1637 | 1603 | break; |
1604 | + | |
1605 | + /* Essentially R_SPARC_WPLT30 relocs against __tls_get_addr. */ | |
1606 | + h = (struct elf_link_hash_entry *) | |
1607 | + bfd_link_hash_lookup (info->hash, "__tls_get_addr", TRUE, | |
1608 | + FALSE, TRUE); | |
1638 | 1609 | /* Fall through */ |
1639 | 1610 | |
1640 | - case R_SPARC_PLT32: | |
1641 | 1611 | case R_SPARC_WPLT30: |
1612 | + case R_SPARC_PLT32: | |
1613 | + case R_SPARC_PLT64: | |
1642 | 1614 | case R_SPARC_HIPLT22: |
1643 | 1615 | case R_SPARC_LOPLT10: |
1644 | 1616 | case R_SPARC_PCPLT32: |
1645 | 1617 | case R_SPARC_PCPLT22: |
1646 | 1618 | case R_SPARC_PCPLT10: |
1647 | - case R_SPARC_PLT64: | |
1648 | - /* This symbol requires a procedure linkage table entry. We | |
1649 | - actually build the entry in adjust_dynamic_symbol, | |
1619 | + /* This symbol requires a procedure linkage table entry. | |
1620 | + We actually build the entry in adjust_dynamic_symbol, | |
1650 | 1621 | because this might be a case of linking PIC code without |
1651 | 1622 | linking in any dynamic objects, in which case we don't |
1652 | 1623 | need to generate a procedure linkage table after all. */ |
@@ -1659,7 +1630,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1659 | 1630 | reloc for a local symbol if you assemble a call from |
1660 | 1631 | one section to another when using -K pic. We treat |
1661 | 1632 | it as WDISP30. */ |
1662 | - if (ELF32_R_TYPE (rel->r_info) == R_SPARC_PLT32) | |
1633 | + if (r_type == R_SPARC_PLT32) | |
1663 | 1634 | goto r_sparc_plt32; |
1664 | 1635 | break; |
1665 | 1636 | } |
@@ -1675,14 +1646,9 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, | ||
1675 | 1646 | |
1676 | 1647 | h->needs_plt = 1; |
1677 | 1648 | |
1678 | - { | |
1679 | - int this_r_type; | |
1649 | + if (r_type == R_SPARC_PLT32 || r_type == R_SPARC_PLT64) | |
1650 | + goto r_sparc_plt32; | |
1680 | 1651 | |
1681 | - this_r_type = SPARC_ELF_R_TYPE (rel->r_info); | |
1682 | - if (this_r_type == R_SPARC_PLT32 | |
1683 | - || this_r_type == R_SPARC_PLT64) | |
1684 | - goto r_sparc_plt32; | |
1685 | - } | |
1686 | 1652 | h->plt.refcount += 1; |
1687 | 1653 | |
1688 | 1654 | eh = (struct _bfd_sparc_elf_link_hash_entry *) h; |
@@ -1886,9 +1852,7 @@ _bfd_sparc_elf_gc_mark_hook (asection *sec, | ||
1886 | 1852 | return NULL; |
1887 | 1853 | } |
1888 | 1854 | |
1889 | - /* FIXME: The test here, in check_relocs and in relocate_section | |
1890 | - dealing with TLS optimization, ought to be !bfd_link_executable (info). */ | |
1891 | - if (bfd_link_pic (info)) | |
1855 | + if (!bfd_link_executable (info)) | |
1892 | 1856 | { |
1893 | 1857 | switch (SPARC_ELF_R_TYPE (rel->r_info)) |
1894 | 1858 | { |
@@ -2227,7 +2191,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) | ||
2227 | 2191 | /* If R_SPARC_TLS_IE_{HI22,LO10} symbol is now local to the binary, |
2228 | 2192 | make it a R_SPARC_TLS_LE_{HI22,LO10} requiring no TLS entry. */ |
2229 | 2193 | if (h->got.refcount > 0 |
2230 | - && !bfd_link_pic (info) | |
2194 | + && bfd_link_executable (info) | |
2231 | 2195 | && h->dynindx == -1 |
2232 | 2196 | && _bfd_sparc_elf_hash_entry(h)->tls_type == GOT_TLS_IE) |
2233 | 2197 | h->got.offset = (bfd_vma) -1; |
@@ -2963,8 +2927,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
2963 | 2927 | bfd_set_error (bfd_error_bad_value); |
2964 | 2928 | return FALSE; |
2965 | 2929 | } |
2966 | - howto = _bfd_sparc_elf_howto_table + r_type; | |
2967 | 2930 | |
2931 | + howto = _bfd_sparc_elf_howto_table + r_type; | |
2968 | 2932 | r_symndx = SPARC_ELF_R_SYMNDX (htab, rel->r_info); |
2969 | 2933 | h = NULL; |
2970 | 2934 | sym = NULL; |
@@ -3131,8 +3095,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3131 | 3095 | } |
3132 | 3096 | |
3133 | 3097 | eh = (struct _bfd_sparc_elf_link_hash_entry *) h; |
3134 | - resolved_to_zero = (eh != NULL | |
3135 | - && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh)); | |
3098 | + resolved_to_zero = eh && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh); | |
3136 | 3099 | |
3137 | 3100 | switch (r_type) |
3138 | 3101 | { |
@@ -3378,8 +3341,7 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3378 | 3341 | case R_SPARC_H34: |
3379 | 3342 | case R_SPARC_UA64: |
3380 | 3343 | r_sparc_plt32: |
3381 | - if ((input_section->flags & SEC_ALLOC) == 0 | |
3382 | - || is_vxworks_tls) | |
3344 | + if ((input_section->flags & SEC_ALLOC) == 0 || is_vxworks_tls) | |
3383 | 3345 | break; |
3384 | 3346 | |
3385 | 3347 | /* Copy dynamic function pointer relocations. Don't generate |
@@ -3551,40 +3513,19 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3551 | 3513 | break; |
3552 | 3514 | |
3553 | 3515 | case R_SPARC_TLS_GD_HI22: |
3554 | - if (! ABI_64_P (input_bfd) | |
3555 | - && ! _bfd_sparc_elf_tdata (input_bfd)->has_tlsgd) | |
3556 | - { | |
3557 | - /* R_SPARC_REV32 used the same reloc number as | |
3558 | - R_SPARC_TLS_GD_HI22. */ | |
3559 | - r_type = R_SPARC_REV32; | |
3560 | - break; | |
3561 | - } | |
3562 | - /* Fall through */ | |
3563 | - | |
3564 | 3516 | case R_SPARC_TLS_GD_LO10: |
3565 | 3517 | case R_SPARC_TLS_IE_HI22: |
3566 | 3518 | case R_SPARC_TLS_IE_LO10: |
3567 | - r_type = sparc_elf_tls_transition (info, input_bfd, r_type, h == NULL); | |
3568 | - tls_type = GOT_UNKNOWN; | |
3569 | - if (h == NULL && local_got_offsets) | |
3519 | + r_type = sparc_elf_tls_transition (info, input_bfd, r_type, | |
3520 | + h == NULL || h->dynindx == -1); | |
3521 | + if (r_type == R_SPARC_REV32) | |
3522 | + break; | |
3523 | + if (h != NULL) | |
3524 | + tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type; | |
3525 | + else if (local_got_offsets) | |
3570 | 3526 | tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx]; |
3571 | - else if (h != NULL) | |
3572 | - { | |
3573 | - tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type; | |
3574 | - if (!bfd_link_pic (info) | |
3575 | - && h->dynindx == -1 | |
3576 | - && tls_type == GOT_TLS_IE) | |
3577 | - switch (SPARC_ELF_R_TYPE (rel->r_info)) | |
3578 | - { | |
3579 | - case R_SPARC_TLS_GD_HI22: | |
3580 | - case R_SPARC_TLS_IE_HI22: | |
3581 | - r_type = R_SPARC_TLS_LE_HIX22; | |
3582 | - break; | |
3583 | - default: | |
3584 | - r_type = R_SPARC_TLS_LE_LOX10; | |
3585 | - break; | |
3586 | - } | |
3587 | - } | |
3527 | + else | |
3528 | + tls_type = GOT_UNKNOWN; | |
3588 | 3529 | if (tls_type == GOT_TLS_IE) |
3589 | 3530 | switch (r_type) |
3590 | 3531 | { |
@@ -3695,7 +3636,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3695 | 3636 | |
3696 | 3637 | case R_SPARC_TLS_LDM_HI22: |
3697 | 3638 | case R_SPARC_TLS_LDM_LO10: |
3698 | - if (! bfd_link_pic (info)) | |
3639 | + /* LD -> LE */ | |
3640 | + if (bfd_link_executable (info)) | |
3699 | 3641 | { |
3700 | 3642 | bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
3701 | 3643 | continue; |
@@ -3706,43 +3648,42 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3706 | 3648 | |
3707 | 3649 | case R_SPARC_TLS_LDO_HIX22: |
3708 | 3650 | case R_SPARC_TLS_LDO_LOX10: |
3709 | - if (bfd_link_pic (info)) | |
3651 | + /* LD -> LE */ | |
3652 | + if (bfd_link_executable (info)) | |
3653 | + { | |
3654 | + if (r_type == R_SPARC_TLS_LDO_HIX22) | |
3655 | + r_type = R_SPARC_TLS_LE_HIX22; | |
3656 | + else | |
3657 | + r_type = R_SPARC_TLS_LE_LOX10; | |
3658 | + } | |
3659 | + else | |
3710 | 3660 | { |
3711 | 3661 | relocation -= dtpoff_base (info); |
3712 | 3662 | break; |
3713 | 3663 | } |
3714 | - | |
3715 | - r_type = (r_type == R_SPARC_TLS_LDO_HIX22 | |
3716 | - ? R_SPARC_TLS_LE_HIX22 : R_SPARC_TLS_LE_LOX10); | |
3717 | 3664 | /* Fall through. */ |
3718 | 3665 | |
3719 | 3666 | case R_SPARC_TLS_LE_HIX22: |
3720 | 3667 | case R_SPARC_TLS_LE_LOX10: |
3721 | - if (bfd_link_pic (info)) | |
3668 | + if (!bfd_link_executable (info)) | |
3722 | 3669 | { |
3723 | 3670 | Elf_Internal_Rela outrel; |
3724 | - bfd_boolean skip; | |
3725 | - | |
3726 | - BFD_ASSERT (sreloc != NULL); | |
3727 | - skip = FALSE; | |
3728 | - outrel.r_offset = | |
3729 | - _bfd_elf_section_offset (output_bfd, info, input_section, | |
3730 | - rel->r_offset); | |
3731 | - if (outrel.r_offset == (bfd_vma) -1) | |
3732 | - skip = TRUE; | |
3733 | - else if (outrel.r_offset == (bfd_vma) -2) | |
3734 | - skip = TRUE; | |
3735 | - outrel.r_offset += (input_section->output_section->vma | |
3736 | - + input_section->output_offset); | |
3737 | - if (skip) | |
3671 | + bfd_vma offset | |
3672 | + = _bfd_elf_section_offset (output_bfd, info, input_section, | |
3673 | + rel->r_offset); | |
3674 | + if (offset == (bfd_vma) -1 || offset == (bfd_vma) -2) | |
3738 | 3675 | memset (&outrel, 0, sizeof outrel); |
3739 | 3676 | else |
3740 | 3677 | { |
3678 | + outrel.r_offset = offset | |
3679 | + + input_section->output_section->vma | |
3680 | + + input_section->output_offset; | |
3741 | 3681 | outrel.r_info = SPARC_ELF_R_INFO (htab, NULL, 0, r_type); |
3742 | - outrel.r_addend = relocation - dtpoff_base (info) | |
3743 | - + rel->r_addend; | |
3682 | + outrel.r_addend | |
3683 | + = relocation - dtpoff_base (info) + rel->r_addend; | |
3744 | 3684 | } |
3745 | 3685 | |
3686 | + BFD_ASSERT (sreloc != NULL); | |
3746 | 3687 | sparc_elf_append_rela (output_bfd, sreloc, &outrel); |
3747 | 3688 | continue; |
3748 | 3689 | } |
@@ -3750,7 +3691,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3750 | 3691 | break; |
3751 | 3692 | |
3752 | 3693 | case R_SPARC_TLS_LDM_CALL: |
3753 | - if (! bfd_link_pic (info)) | |
3694 | + /* LD -> LE */ | |
3695 | + if (bfd_link_executable (info)) | |
3754 | 3696 | { |
3755 | 3697 | /* mov %g0, %o0 */ |
3756 | 3698 | bfd_put_32 (output_bfd, 0x90100000, contents + rel->r_offset); |
@@ -3759,20 +3701,22 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3759 | 3701 | /* Fall through */ |
3760 | 3702 | |
3761 | 3703 | case R_SPARC_TLS_GD_CALL: |
3762 | - tls_type = GOT_UNKNOWN; | |
3763 | - if (h == NULL && local_got_offsets) | |
3704 | + if (h != NULL) | |
3705 | + tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type; | |
3706 | + else if (local_got_offsets) | |
3764 | 3707 | tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx]; |
3765 | - else if (h != NULL) | |
3766 | - tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type; | |
3767 | - if (! bfd_link_pic (info) | |
3708 | + else | |
3709 | + tls_type = GOT_UNKNOWN; | |
3710 | + /* GD -> IE or LE */ | |
3711 | + if (bfd_link_executable (info) | |
3768 | 3712 | || (r_type == R_SPARC_TLS_GD_CALL && tls_type == GOT_TLS_IE)) |
3769 | 3713 | { |
3770 | 3714 | Elf_Internal_Rela *rel2; |
3771 | 3715 | bfd_vma insn; |
3772 | 3716 | |
3773 | - if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) | |
3717 | + /* GD -> LE */ | |
3718 | + if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1)) | |
3774 | 3719 | { |
3775 | - /* GD -> LE */ | |
3776 | 3720 | bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
3777 | 3721 | continue; |
3778 | 3722 | } |
@@ -3835,12 +3779,14 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3835 | 3779 | goto r_sparc_wplt30; |
3836 | 3780 | |
3837 | 3781 | case R_SPARC_TLS_GD_ADD: |
3838 | - tls_type = GOT_UNKNOWN; | |
3839 | - if (h == NULL && local_got_offsets) | |
3782 | + if (h != NULL) | |
3783 | + tls_type = _bfd_sparc_elf_hash_entry (h)->tls_type; | |
3784 | + else if (local_got_offsets) | |
3840 | 3785 | tls_type = _bfd_sparc_elf_local_got_tls_type (input_bfd) [r_symndx]; |
3841 | - else if (h != NULL) | |
3842 | - tls_type = _bfd_sparc_elf_hash_entry(h)->tls_type; | |
3843 | - if (! bfd_link_pic (info) || tls_type == GOT_TLS_IE) | |
3786 | + else | |
3787 | + tls_type = GOT_UNKNOWN; | |
3788 | + /* GD -> IE or LE */ | |
3789 | + if (bfd_link_executable (info) || tls_type == GOT_TLS_IE) | |
3844 | 3790 | { |
3845 | 3791 | /* add %reg1, %reg2, %reg3, %tgd_add(foo) |
3846 | 3792 | changed into IE: |
@@ -3848,21 +3794,23 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3848 | 3794 | or LE: |
3849 | 3795 | add %g7, %reg2, %reg3. */ |
3850 | 3796 | bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
3851 | - if ((h != NULL && h->dynindx != -1) || bfd_link_pic (info)) | |
3852 | - relocation = insn | (ABI_64_P (output_bfd) ? 0xc0580000 : 0xc0000000); | |
3853 | - else | |
3797 | + if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1)) | |
3854 | 3798 | relocation = (insn & ~0x7c000) | 0x1c000; |
3799 | + else | |
3800 | + relocation = insn | (ABI_64_P (output_bfd) ? 0xc0580000 : 0xc0000000); | |
3855 | 3801 | bfd_put_32 (output_bfd, relocation, contents + rel->r_offset); |
3856 | 3802 | } |
3857 | 3803 | continue; |
3858 | 3804 | |
3859 | 3805 | case R_SPARC_TLS_LDM_ADD: |
3860 | - if (! bfd_link_pic (info)) | |
3806 | + /* LD -> LE */ | |
3807 | + if (bfd_link_executable (info)) | |
3861 | 3808 | bfd_put_32 (output_bfd, SPARC_NOP, contents + rel->r_offset); |
3862 | 3809 | continue; |
3863 | 3810 | |
3864 | 3811 | case R_SPARC_TLS_LDO_ADD: |
3865 | - if (! bfd_link_pic (info)) | |
3812 | + /* LD -> LE */ | |
3813 | + if (bfd_link_executable (info)) | |
3866 | 3814 | { |
3867 | 3815 | /* Change rs1 into %g7. */ |
3868 | 3816 | bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
@@ -3873,7 +3821,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, | ||
3873 | 3821 | |
3874 | 3822 | case R_SPARC_TLS_IE_LD: |
3875 | 3823 | case R_SPARC_TLS_IE_LDX: |
3876 | - if (! bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) | |
3824 | + /* IE -> LE */ | |
3825 | + if (bfd_link_executable (info) && (h == NULL || h->dynindx == -1)) | |
3877 | 3826 | { |
3878 | 3827 | bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); |
3879 | 3828 | int rs2 = insn & 0x1f; |
@@ -1,3 +1,7 @@ | ||
1 | +2018-02-06 Eric Botcazou <ebotcazou@adacore.com> | |
2 | + | |
3 | + * gcc-plugin.m4 (GCC_ENABLE_PLUGINS): Remove -q option passed to grep. | |
4 | + | |
1 | 5 | 2018-01-10 Nick Clifton <nickc@redhat.com> |
2 | 6 | |
3 | 7 | * Sync with GCC sources: |
@@ -60,14 +60,14 @@ AC_DEFUN([GCC_ENABLE_PLUGINS], | ||
60 | 60 | if test "x$export_sym_check" != x; then |
61 | 61 | echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c |
62 | 62 | ${CC} ${CFLAGS} ${LDFLAGS} conftest.c -o conftest$ac_exeext > /dev/null 2>&1 |
63 | - if $export_sym_check conftest$ac_exeext | grep -q foobar > /dev/null; then | |
63 | + if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then | |
64 | 64 | : # No need to use a flag |
65 | 65 | AC_MSG_RESULT([yes]) |
66 | 66 | else |
67 | 67 | AC_MSG_RESULT([yes]) |
68 | 68 | AC_MSG_CHECKING([for -rdynamic]) |
69 | 69 | ${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c -o conftest$ac_exeext > /dev/null 2>&1 |
70 | - if $export_sym_check conftest$ac_exeext | grep -q foobar > /dev/null; then | |
70 | + if $export_sym_check conftest$ac_exeext | grep foobar > /dev/null; then | |
71 | 71 | plugin_rdynamic=yes |
72 | 72 | pluginlibs="-rdynamic" |
73 | 73 | else |
@@ -1,3 +1,12 @@ | ||
1 | +2018-02-06 Eric Botcazou <ebotcazou@adacore.com> | |
2 | + | |
3 | + * testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC. | |
4 | + (pr22263-1): Pass AFLAGS_PIC to the assembler. | |
5 | + * testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions. | |
6 | + * testsuite/ld-sparc/tlspie32.dd: Adjust to above. | |
7 | + * testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions. | |
8 | + * testsuite/ld-sparc/tlspie64.dd: Adjust to above. | |
9 | + | |
1 | 10 | 2018-02-05 Renlin Li <renlin.li@arm.com> |
2 | 11 | |
3 | 12 | PR ld/22764 |
@@ -37,12 +37,18 @@ if { [which $CC] == 0 } { | ||
37 | 37 | return |
38 | 38 | } |
39 | 39 | |
40 | +# This target requires extra GAS options when building PIC/PIE code. | |
41 | +set AFLAGS_PIC "" | |
42 | +if [istarget "sparc*-*-*"] { | |
43 | + append AFLAGS_PIC " -K PIC" | |
44 | +} | |
45 | + | |
40 | 46 | run_ld_link_tests [list \ |
41 | 47 | [list \ |
42 | 48 | "Build pr22263-1" \ |
43 | 49 | "-pie -e _start -z text" \ |
44 | 50 | "" \ |
45 | - "" \ | |
51 | + "$AFLAGS_PIC" \ | |
46 | 52 | { pr22263-1a.c pr22263-1b.c } \ |
47 | 53 | {{readelf -r pr22263-1.rd}} \ |
48 | 54 | "pr22263-1" \ |
@@ -10,9 +10,56 @@ | ||
10 | 10 | |
11 | 11 | Disassembly of section .text: |
12 | 12 | |
13 | -0[0-9a-f]+ <get_gdp>: | |
13 | +0[0-9a-f]+ <foo-0x8>: | |
14 | + +[0-9a-f]+: 81 c3 e0 08 retl | |
15 | + +[0-9a-f]+: ae 03 c0 17 add %o7, %l7, %l7 | |
16 | + | |
17 | +0[0-9a-f]+ <foo>: | |
18 | + +[0-9a-f]+: 9d e3 bf 98 save %sp, -104, %sp | |
19 | + +[0-9a-f]+: 2f 00 00 40 sethi %hi\(0x10000\), %l7 | |
20 | + +[0-9a-f]+: 7f ff ff fc call [0-9a-f]+ <.*> | |
21 | + +[0-9a-f]+: ae 05 e1 60 add %l7, 0x160, %l7 ! 10160 <.*> | |
22 | + +[0-9a-f]+: 01 00 00 00 nop | |
23 | + +[0-9a-f]+: 01 00 00 00 nop | |
24 | + +[0-9a-f]+: 01 00 00 00 nop | |
25 | + +[0-9a-f]+: 01 00 00 00 nop | |
26 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
27 | + +[0-9a-f]+: 82 00 60 04 add %g1, 4, %g1 ! 4 <.*> | |
28 | + +[0-9a-f]+: d0 05 c0 01 ld \[ %l7 \+ %g1 ], %o0 | |
29 | + +[0-9a-f]+: 01 00 00 00 nop | |
30 | + +[0-9a-f]+: 90 01 c0 08 add %g7, %o0, %o0 | |
31 | + +[0-9a-f]+: 01 00 00 00 nop | |
32 | + +[0-9a-f]+: 01 00 00 00 nop | |
33 | + +[0-9a-f]+: 01 00 00 00 nop | |
34 | + +[0-9a-f]+: 01 00 00 00 nop | |
14 | 35 | +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 |
15 | - +[0-9a-f]+: 82 00 60 04 add %g1, 4, %g1 ! 4 <tls_gd\+0x4> | |
16 | - +[0-9a-f]+: 90 05 c0 01 add %l7, %g1, %o0 | |
17 | - +[0-9a-f]+: 40 00 40 43 call [0-9a-f]+ <__tls_get_addr@plt> | |
36 | + +[0-9a-f]+: 82 18 7f f4 xor %g1, -12, %g1 | |
37 | + +[0-9a-f]+: 90 01 c0 01 add %g7, %g1, %o0 | |
38 | + +[0-9a-f]+: 01 00 00 00 nop | |
39 | + +[0-9a-f]+: 01 00 00 00 nop | |
40 | + +[0-9a-f]+: 01 00 00 00 nop | |
41 | + +[0-9a-f]+: 01 00 00 00 nop | |
42 | + +[0-9a-f]+: 01 00 00 00 nop | |
43 | + +[0-9a-f]+: 01 00 00 00 nop | |
44 | + +[0-9a-f]+: 01 00 00 00 nop | |
45 | + +[0-9a-f]+: 01 00 00 00 nop | |
46 | + +[0-9a-f]+: 01 00 00 00 nop | |
47 | + +[0-9a-f]+: 90 10 00 00 mov %g0, %o0 | |
48 | + +[0-9a-f]+: 01 00 00 00 nop | |
49 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
50 | + +[0-9a-f]+: 82 18 7f f8 xor %g1, -8, %g1 | |
51 | + +[0-9a-f]+: 82 01 c0 01 add %g7, %g1, %g1 | |
52 | + +[0-9a-f]+: 01 00 00 00 nop | |
53 | + +[0-9a-f]+: 01 00 00 00 nop | |
54 | + +[0-9a-f]+: 01 00 00 00 nop | |
55 | + +[0-9a-f]+: 01 00 00 00 nop | |
56 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
57 | + +[0-9a-f]+: 82 18 7f fc xor %g1, -4, %g1 | |
58 | + +[0-9a-f]+: 01 00 00 00 nop | |
59 | + +[0-9a-f]+: 82 01 c0 01 add %g7, %g1, %g1 | |
60 | + +[0-9a-f]+: 01 00 00 00 nop | |
61 | + +[0-9a-f]+: 01 00 00 00 nop | |
62 | + +[0-9a-f]+: 01 00 00 00 nop | |
18 | 63 | +[0-9a-f]+: 01 00 00 00 nop |
64 | + +[0-9a-f]+: 81 c7 e0 08 ret | |
65 | + +[0-9a-f]+: 81 e8 00 00 restore |
@@ -1,20 +1,70 @@ | ||
1 | - .section ".text" | |
2 | - .global tls_gd | |
3 | 1 | .section .tbss,"awT",@nobits |
2 | + .global tls_gd | |
4 | 3 | .align 4 |
5 | 4 | .type tls_gd, #object |
6 | 5 | .size tls_gd, 4 |
7 | 6 | tls_gd: |
8 | 7 | .skip 4 |
8 | + .global tls_ld | |
9 | + .align 4 | |
10 | + .type tls_ld, #object | |
11 | + .size tls_ld, 4 | |
12 | +tls_ld: | |
13 | + .skip 4 | |
14 | + .global tls_ie | |
15 | + .align 4 | |
16 | + .type tls_ie, #object | |
17 | + .size tls_ie, 4 | |
18 | +tls_ie: | |
19 | + .skip 4 | |
9 | 20 | .section ".text" |
21 | +.LLGETPC0: | |
22 | + retl | |
23 | + add %o7, %l7, %l7 | |
10 | 24 | .align 4 |
11 | - .global get_gdp | |
12 | - .type get_gdp, #function | |
25 | + .global foo | |
26 | + .type foo, #function | |
13 | 27 | .proc 0104 |
14 | -get_gdp: | |
28 | +foo: | |
29 | + save %sp, -104, %sp | |
30 | + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 | |
31 | + call .LLGETPC0 | |
32 | + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 | |
33 | + nop;nop;nop;nop | |
34 | + | |
35 | + /* GD -> IE with global variable not defined in executable */ | |
36 | + sethi %tgd_hi22(sG1), %g1 | |
37 | + add %g1, %tgd_lo10(sG1), %g1 | |
38 | + add %l7, %g1, %o0, %tgd_add(sG1) | |
39 | + call __tls_get_addr, %tgd_call(sG1) | |
40 | + nop | |
41 | + nop;nop;nop;nop | |
42 | + | |
43 | + /* GD -> LE with global variable defined in executable */ | |
15 | 44 | sethi %tgd_hi22(tls_gd), %g1 |
16 | 45 | add %g1, %tgd_lo10(tls_gd), %g1 |
17 | 46 | add %l7, %g1, %o0, %tgd_add(tls_gd) |
18 | 47 | call __tls_get_addr, %tgd_call(tls_gd) |
19 | 48 | nop |
20 | - .size get_gdp, .-get_gdp | |
49 | + nop;nop;nop;nop | |
50 | + | |
51 | + /* LD -> LE with global variable defined in executable */ | |
52 | + sethi %tldm_hi22(tls_ld), %g1 | |
53 | + add %g1, %tldm_lo10(tls_ld), %g1 | |
54 | + add %l7, %g1, %o0, %tldm_add(tls_ld) | |
55 | + call __tls_get_addr, %tldm_call(tls_ld) | |
56 | + nop | |
57 | + sethi %tldo_hix22(tls_ld), %g1 | |
58 | + xor %g1, %tldo_lox10(tls_ld), %g1 | |
59 | + add %o0, %g1, %g1, %tldo_add(tls_ld) | |
60 | + nop;nop;nop;nop | |
61 | + | |
62 | + /* IE -> LE with global variable defined in executable */ | |
63 | + sethi %tie_hi22(tls_ie), %g1 | |
64 | + add %g1, %tie_lo10(tls_ie), %g1 | |
65 | + ld [%l7 + %g1], %g1, %tie_ld(tls_ie) | |
66 | + add %g7, %g1, %g1, %tie_add(tls_ie) | |
67 | + nop;nop;nop;nop | |
68 | + | |
69 | + ret | |
70 | + restore |
@@ -10,9 +10,56 @@ | ||
10 | 10 | |
11 | 11 | Disassembly of section .text: |
12 | 12 | |
13 | -0[0-9a-f]+ <get_gdp>: | |
13 | +0[0-9a-f]+ <foo-0x8>: | |
14 | + +[0-9a-f]+: 81 c3 e0 08 retl | |
15 | + +[0-9a-f]+: ae 03 c0 17 add %o7, %l7, %l7 | |
16 | + | |
17 | +0[0-9a-f]+ <foo>: | |
18 | + +[0-9a-f]+: 9d e3 bf 60 save %sp, -160, %sp | |
19 | + +[0-9a-f]+: 2f 00 04 00 sethi %hi\(0x100000\), %l7 | |
20 | + +[0-9a-f]+: 7f ff ff fc call [0-9a-f]+ <.*> | |
21 | + +[0-9a-f]+: ae 05 e2 08 add %l7, 0x208, %l7 ! 100208 <.*> | |
22 | + +[0-9a-f]+: 01 00 00 00 nop | |
23 | + +[0-9a-f]+: 01 00 00 00 nop | |
24 | + +[0-9a-f]+: 01 00 00 00 nop | |
25 | + +[0-9a-f]+: 01 00 00 00 nop | |
26 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
27 | + +[0-9a-f]+: 82 00 60 08 add %g1, 8, %g1 ! 8 <.*> | |
28 | + +[0-9a-f]+: d0 5d c0 01 ldx \[ %l7 \+ %g1 ], %o0 | |
29 | + +[0-9a-f]+: 01 00 00 00 nop | |
30 | + +[0-9a-f]+: 90 01 c0 08 add %g7, %o0, %o0 | |
31 | + +[0-9a-f]+: 01 00 00 00 nop | |
32 | + +[0-9a-f]+: 01 00 00 00 nop | |
33 | + +[0-9a-f]+: 01 00 00 00 nop | |
34 | + +[0-9a-f]+: 01 00 00 00 nop | |
14 | 35 | +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 |
15 | - +[0-9a-f]+: 82 00 60 08 add %g1, 8, %g1 ! 8 <tls_gd\+0x8> | |
16 | - +[0-9a-f]+: 90 05 c0 01 add %l7, %g1, %o0 | |
17 | - +[0-9a-f]+: 40 04 00 bb call [0-9a-f]+ <__tls_get_addr@plt> | |
36 | + +[0-9a-f]+: 82 18 7f f4 xor %g1, -12, %g1 | |
37 | + +[0-9a-f]+: 90 01 c0 01 add %g7, %g1, %o0 | |
38 | + +[0-9a-f]+: 01 00 00 00 nop | |
39 | + +[0-9a-f]+: 01 00 00 00 nop | |
40 | + +[0-9a-f]+: 01 00 00 00 nop | |
41 | + +[0-9a-f]+: 01 00 00 00 nop | |
42 | + +[0-9a-f]+: 01 00 00 00 nop | |
43 | + +[0-9a-f]+: 01 00 00 00 nop | |
44 | + +[0-9a-f]+: 01 00 00 00 nop | |
45 | + +[0-9a-f]+: 01 00 00 00 nop | |
46 | + +[0-9a-f]+: 01 00 00 00 nop | |
47 | + +[0-9a-f]+: 90 10 00 00 mov %g0, %o0 | |
48 | + +[0-9a-f]+: 01 00 00 00 nop | |
49 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
50 | + +[0-9a-f]+: 82 18 7f f8 xor %g1, -8, %g1 | |
51 | + +[0-9a-f]+: 82 01 c0 01 add %g7, %g1, %g1 | |
52 | + +[0-9a-f]+: 01 00 00 00 nop | |
53 | + +[0-9a-f]+: 01 00 00 00 nop | |
54 | + +[0-9a-f]+: 01 00 00 00 nop | |
55 | + +[0-9a-f]+: 01 00 00 00 nop | |
56 | + +[0-9a-f]+: 03 00 00 00 sethi %hi\(0\), %g1 | |
57 | + +[0-9a-f]+: 82 18 7f fc xor %g1, -4, %g1 | |
58 | + +[0-9a-f]+: 01 00 00 00 nop | |
59 | + +[0-9a-f]+: 82 01 c0 01 add %g7, %g1, %g1 | |
60 | + +[0-9a-f]+: 01 00 00 00 nop | |
61 | + +[0-9a-f]+: 01 00 00 00 nop | |
62 | + +[0-9a-f]+: 01 00 00 00 nop | |
18 | 63 | +[0-9a-f]+: 01 00 00 00 nop |
64 | + +[0-9a-f]+: 81 c7 e0 08 ret | |
65 | + +[0-9a-f]+: 81 e8 00 00 restore |
@@ -1,20 +1,70 @@ | ||
1 | - .section ".text" | |
2 | - .global tls_gd | |
3 | 1 | .section .tbss,"awT",@nobits |
2 | + .global tls_gd | |
4 | 3 | .align 4 |
5 | 4 | .type tls_gd, #object |
6 | 5 | .size tls_gd, 4 |
7 | 6 | tls_gd: |
8 | 7 | .skip 4 |
8 | + .global tls_ld | |
9 | + .align 4 | |
10 | + .type tls_ld, #object | |
11 | + .size tls_ld, 4 | |
12 | +tls_ld: | |
13 | + .skip 4 | |
14 | + .global tls_ie | |
15 | + .align 4 | |
16 | + .type tls_ie, #object | |
17 | + .size tls_ie, 4 | |
18 | +tls_ie: | |
19 | + .skip 4 | |
9 | 20 | .section ".text" |
21 | +.LLGETPC0: | |
22 | + retl | |
23 | + add %o7, %l7, %l7 | |
10 | 24 | .align 4 |
11 | - .global get_gdp | |
12 | - .type get_gdp, #function | |
25 | + .global foo | |
26 | + .type foo, #function | |
13 | 27 | .proc 0104 |
14 | -get_gdp: | |
28 | +foo: | |
29 | + save %sp, -160, %sp | |
30 | + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 | |
31 | + call .LLGETPC0 | |
32 | + add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7 | |
33 | + nop;nop;nop;nop | |
34 | + | |
35 | + /* GD -> IE with global variable not defined in executable */ | |
36 | + sethi %tgd_hi22(sG1), %g1 | |
37 | + add %g1, %tgd_lo10(sG1), %g1 | |
38 | + add %l7, %g1, %o0, %tgd_add(sG1) | |
39 | + call __tls_get_addr, %tgd_call(sG1) | |
40 | + nop | |
41 | + nop;nop;nop;nop | |
42 | + | |
43 | + /* GD -> LE with global variable defined in executable */ | |
15 | 44 | sethi %tgd_hi22(tls_gd), %g1 |
16 | 45 | add %g1, %tgd_lo10(tls_gd), %g1 |
17 | 46 | add %l7, %g1, %o0, %tgd_add(tls_gd) |
18 | 47 | call __tls_get_addr, %tgd_call(tls_gd) |
19 | 48 | nop |
20 | - .size get_gdp, .-get_gdp | |
49 | + nop;nop;nop;nop | |
50 | + | |
51 | + /* LD -> LE with global variable defined in executable */ | |
52 | + sethi %tldm_hi22(tls_ld), %g1 | |
53 | + add %g1, %tldm_lo10(tls_ld), %g1 | |
54 | + add %l7, %g1, %o0, %tldm_add(tls_ld) | |
55 | + call __tls_get_addr, %tldm_call(tls_ld) | |
56 | + nop | |
57 | + sethi %tldo_hix22(tls_ld), %g1 | |
58 | + xor %g1, %tldo_lox10(tls_ld), %g1 | |
59 | + add %o0, %g1, %g1, %tldo_add(tls_ld) | |
60 | + nop;nop;nop;nop | |
61 | + | |
62 | + /* IE -> LE with global variable defined in executable */ | |
63 | + sethi %tie_hi22(tls_ie), %g1 | |
64 | + add %g1, %tie_lo10(tls_ie), %g1 | |
65 | + ldx [%l7 + %g1], %g1, %tie_ldx(tls_ie) | |
66 | + add %g7, %g1, %g1, %tie_add(tls_ie) | |
67 | + nop;nop;nop;nop | |
68 | + | |
69 | + ret | |
70 | + restore |