forked from Imagelibrary/binutils-gdb
bfd/
* bfd/elf32-ppc.c (struct ppc_elf_link_hash_entry): Add new field has_sda_refs. (ppc_elf_copy_indirect_symbol): Copy has_sda_refs. (ppc_elf_check_relocs): Set has_sda_refs. (ppc_elf_adjust_dynamic_symbol): Check has_sda_refs before eliminating copy relocations. Use has_sda_refs to place variables in .sbss. (ppc_elf_finish_dynamic_symbol): Use has_sda_refs to place variables in .sbss. ld/testsuite/ * ld-powerpc/sdalib.s, ld-powerpc/sdadyn.s, ld-powerpc/sdadyn.d: New files. * ld-powerpc/powerpc.exp: Run the new test.
This commit is contained in:
@@ -1,3 +1,14 @@
|
|||||||
|
2005-05-20 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* bfd/elf32-ppc.c (struct ppc_elf_link_hash_entry): Add new field
|
||||||
|
has_sda_refs.
|
||||||
|
(ppc_elf_copy_indirect_symbol): Copy has_sda_refs.
|
||||||
|
(ppc_elf_check_relocs): Set has_sda_refs.
|
||||||
|
(ppc_elf_adjust_dynamic_symbol): Check has_sda_refs before eliminating
|
||||||
|
copy relocations. Use has_sda_refs to place variables in .sbss.
|
||||||
|
(ppc_elf_finish_dynamic_symbol): Use has_sda_refs to place variables in
|
||||||
|
.sbss.
|
||||||
|
|
||||||
2005-05-20 Bob Wilson <bob.wilson@acm.org>
|
2005-05-20 Bob Wilson <bob.wilson@acm.org>
|
||||||
|
|
||||||
* elf32-xtensa.c (bfd_elf_xtensa_reloc): Make sure that
|
* elf32-xtensa.c (bfd_elf_xtensa_reloc): Make sure that
|
||||||
|
|||||||
@@ -2269,6 +2269,10 @@ struct ppc_elf_link_hash_entry
|
|||||||
#define TLS_TLS 16 /* Any TLS reloc. */
|
#define TLS_TLS 16 /* Any TLS reloc. */
|
||||||
#define TLS_TPRELGD 32 /* TPREL reloc resulting from GD->IE. */
|
#define TLS_TPRELGD 32 /* TPREL reloc resulting from GD->IE. */
|
||||||
char tls_mask;
|
char tls_mask;
|
||||||
|
|
||||||
|
/* Nonzero if we have seen a small data relocation referring to this
|
||||||
|
symbol. */
|
||||||
|
unsigned char has_sda_refs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ppc_elf_hash_entry(ent) ((struct ppc_elf_link_hash_entry *) (ent))
|
#define ppc_elf_hash_entry(ent) ((struct ppc_elf_link_hash_entry *) (ent))
|
||||||
@@ -2520,6 +2524,7 @@ ppc_elf_copy_indirect_symbol (const struct elf_backend_data *bed ATTRIBUTE_UNUSE
|
|||||||
}
|
}
|
||||||
|
|
||||||
edir->tls_mask |= eind->tls_mask;
|
edir->tls_mask |= eind->tls_mask;
|
||||||
|
edir->has_sda_refs |= eind->has_sda_refs;
|
||||||
|
|
||||||
/* If called to transfer flags for a weakdef during processing
|
/* If called to transfer flags for a weakdef during processing
|
||||||
of elf_adjust_dynamic_symbol, don't copy non_got_ref.
|
of elf_adjust_dynamic_symbol, don't copy non_got_ref.
|
||||||
@@ -3026,6 +3031,12 @@ ppc_elf_check_relocs (bfd *abfd,
|
|||||||
bad_shared_reloc (abfd, r_type);
|
bad_shared_reloc (abfd, r_type);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
if (h != NULL)
|
||||||
|
{
|
||||||
|
ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
|
||||||
|
/* We may need a copy reloc. */
|
||||||
|
h->non_got_ref = TRUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_PPC_PLT32:
|
case R_PPC_PLT32:
|
||||||
@@ -3923,7 +3934,11 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|
|||||||
if (!h->non_got_ref)
|
if (!h->non_got_ref)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (ELIMINATE_COPY_RELOCS)
|
/* If we didn't find any dynamic relocs in read-only sections, then we'll
|
||||||
|
be keeping the dynamic relocs and avoiding the copy reloc. We can't
|
||||||
|
do this if there are any small data relocations. */
|
||||||
|
if (ELIMINATE_COPY_RELOCS
|
||||||
|
&& !ppc_elf_hash_entry (h)->has_sda_refs)
|
||||||
{
|
{
|
||||||
struct ppc_elf_dyn_relocs *p;
|
struct ppc_elf_dyn_relocs *p;
|
||||||
for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
|
for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
|
||||||
@@ -3933,8 +3948,6 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we didn't find any dynamic relocs in read-only sections, then
|
|
||||||
we'll be keeping the dynamic relocs and avoiding the copy reloc. */
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
h->non_got_ref = 0;
|
h->non_got_ref = 0;
|
||||||
@@ -3952,11 +3965,10 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|
|||||||
both the dynamic object and the regular object will refer to the
|
both the dynamic object and the regular object will refer to the
|
||||||
same memory location for the variable.
|
same memory location for the variable.
|
||||||
|
|
||||||
Of course, if the symbol is sufficiently small, we must instead
|
Of course, if the symbol is referenced using SDAREL relocs, we
|
||||||
allocate it in .sbss. FIXME: It would be better to do this if and
|
must instead allocate it in .sbss. */
|
||||||
only if there were actually SDAREL relocs for that symbol. */
|
|
||||||
|
|
||||||
if (h->size <= elf_gp_size (htab->elf.dynobj))
|
if (ppc_elf_hash_entry (h)->has_sda_refs)
|
||||||
s = htab->dynsbss;
|
s = htab->dynsbss;
|
||||||
else
|
else
|
||||||
s = htab->dynbss;
|
s = htab->dynbss;
|
||||||
@@ -3970,7 +3982,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
|
|||||||
{
|
{
|
||||||
asection *srel;
|
asection *srel;
|
||||||
|
|
||||||
if (h->size <= elf_gp_size (htab->elf.dynobj))
|
if (ppc_elf_hash_entry (h)->has_sda_refs)
|
||||||
srel = htab->relsbss;
|
srel = htab->relsbss;
|
||||||
else
|
else
|
||||||
srel = htab->relbss;
|
srel = htab->relbss;
|
||||||
@@ -6544,7 +6556,7 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
|
|||||||
|
|
||||||
BFD_ASSERT (h->dynindx != -1);
|
BFD_ASSERT (h->dynindx != -1);
|
||||||
|
|
||||||
if (h->size <= elf_gp_size (htab->elf.dynobj))
|
if (ppc_elf_hash_entry (h)->has_sda_refs)
|
||||||
s = htab->relsbss;
|
s = htab->relsbss;
|
||||||
else
|
else
|
||||||
s = htab->relbss;
|
s = htab->relbss;
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
2005-05-20 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
|
* ld-powerpc/sdalib.s, ld-powerpc/sdadyn.s, ld-powerpc/sdadyn.d: New
|
||||||
|
files.
|
||||||
|
* ld-powerpc/powerpc.exp: Run the new test.
|
||||||
|
|
||||||
2005-05-20 Bob Wilson <bob.wilson@acm.org>
|
2005-05-20 Bob Wilson <bob.wilson@acm.org>
|
||||||
|
|
||||||
* ld-undefined/undefined.exp: Revert xfail for xtensa-*-*.
|
* ld-undefined/undefined.exp: Revert xfail for xtensa-*-*.
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ set ppcelftests {
|
|||||||
{{readelf -WSsrl tlsso32.r} {objdump -dr tlsso32.d}
|
{{readelf -WSsrl tlsso32.r} {objdump -dr tlsso32.d}
|
||||||
{objdump -sj.got tlsso32.g} {objdump -sj.tdata tlsso32.t}}
|
{objdump -sj.got tlsso32.g} {objdump -sj.tdata tlsso32.t}}
|
||||||
"tls32.so"}
|
"tls32.so"}
|
||||||
|
{"Shared library with global symbol" "-shared -melf32ppc" "" {sdalib.s}
|
||||||
|
{} "sdalib.so"}
|
||||||
|
{"Dynamic application with SDA" "-melf32ppc tmpdir/sdalib.so" "" {sdadyn.s}
|
||||||
|
{{objdump -R sdadyn.d}} "sdadyn"}
|
||||||
}
|
}
|
||||||
|
|
||||||
set ppc64elftests {
|
set ppc64elftests {
|
||||||
|
|||||||
8
ld/testsuite/ld-powerpc/sdadyn.d
Normal file
8
ld/testsuite/ld-powerpc/sdadyn.d
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
.*: +file format elf32-powerpc
|
||||||
|
|
||||||
|
DYNAMIC RELOCATION RECORDS
|
||||||
|
OFFSET TYPE VALUE
|
||||||
|
#...
|
||||||
|
.* R_PPC_COPY lib_var
|
||||||
|
#pass
|
||||||
3
ld/testsuite/ld-powerpc/sdadyn.s
Normal file
3
ld/testsuite/ld-powerpc/sdadyn.s
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.globl _start
|
||||||
|
_start:
|
||||||
|
lwz 3,lib_var@sda21(0)
|
||||||
4
ld/testsuite/ld-powerpc/sdalib.s
Normal file
4
ld/testsuite/ld-powerpc/sdalib.s
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.globl lib_var
|
||||||
|
.type lib_var, @object
|
||||||
|
lib_var:
|
||||||
|
.word 1
|
||||||
Reference in New Issue
Block a user