* elf.c (_bfd_elf_rela_local_sym): Only call

_bfd_merged_section_offset if merge_info is non-NULL.
	(_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New.
	* elf-bfd.h (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New
	prototypes.
	* elf32-arm.h (elf32_arm_final_link_relocate): Use
	_bfd_elf_section_offset.
	(elf32_arm_relocate_section): Use _bfd_elf_rel_local_sym.
	* elf32-i386.c (elf_i386_relocate_section): Use
	_bfd_elf_section_offset and _bfd_elf_rel_local_sym.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_relocate_section): Use
	_bfd_elf_section_offset.
	* elf32-cris.c (cris_elf_relocate_section): Likewise.
	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
	* elf32-i370.c (i370_elf_relocate_section): Likewise.
	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
	* elf32-mips.c (mips_elf_create_dynamic_relocation): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
	* elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise.
This commit is contained in:
Jakub Jelinek 2001-12-07 11:12:18 +00:00
parent edb6ede1be
commit c629eae01a
20 changed files with 157 additions and 285 deletions

View file

@ -1,3 +1,32 @@
2001-12-07 Jakub Jelinek <jakub@redhat.com>
* elf.c (_bfd_elf_rela_local_sym): Only call
_bfd_merged_section_offset if merge_info is non-NULL.
(_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New.
* elf-bfd.h (_bfd_elf_rel_local_sym, _bfd_elf_section_offset): New
prototypes.
* elf32-arm.h (elf32_arm_final_link_relocate): Use
_bfd_elf_section_offset.
(elf32_arm_relocate_section): Use _bfd_elf_rel_local_sym.
* elf32-i386.c (elf_i386_relocate_section): Use
_bfd_elf_section_offset and _bfd_elf_rel_local_sym.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-sparc.c (elf32_sparc_relocate_section): Use
_bfd_elf_section_offset.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
* elf32-i370.c (i370_elf_relocate_section): Likewise.
* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
* elf32-mips.c (mips_elf_create_dynamic_relocation): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-s390.c (elf_s390_relocate_section): Likewise.
* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
* elfxx-ia64.c (elfNN_ia64_install_dyn_reloc): Likewise.
2001-12-07 Alan Modra <amodra@bigpond.net.au>
* elf32-hppa.c (clobber_millicode_symbols): Don't do anything if

View file

@ -1142,6 +1142,10 @@ extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
extern bfd_vma _bfd_elf_rela_local_sym
PARAMS ((bfd *, Elf_Internal_Sym *, asection *, Elf_Internal_Rela *));
extern bfd_vma _bfd_elf_rel_local_sym
PARAMS ((bfd *, Elf_Internal_Sym *, asection **, bfd_vma));
extern bfd_vma _bfd_elf_section_offset
PARAMS ((bfd *, struct bfd_link_info *, asection *, bfd_vma));
extern unsigned long bfd_elf_hash
PARAMS ((const char *));

View file

@ -6393,7 +6393,8 @@ _bfd_elf_rela_local_sym (abfd, sym, sec, rel)
+ sec->output_offset
+ sym->st_value);
if ((sec->flags & SEC_MERGE)
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION)
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION
&& elf_section_data (sec)->merge_info)
{
asection *msec;
@ -6408,3 +6409,37 @@ _bfd_elf_rela_local_sym (abfd, sym, sec, rel)
}
return relocation;
}
bfd_vma
_bfd_elf_rel_local_sym (abfd, sym, psec, addend)
bfd *abfd;
Elf_Internal_Sym *sym;
asection **psec;
bfd_vma addend;
{
asection *sec = *psec;
if (elf_section_data (sec)->merge_info == NULL)
return sym->st_value + addend;
return _bfd_merged_section_offset (abfd, psec,
elf_section_data (sec)->merge_info,
sym->st_value + addend, (bfd_vma) 0);
}
bfd_vma
_bfd_elf_section_offset (abfd, info, sec, offset)
bfd *abfd;
struct bfd_link_info *info;
asection *sec;
bfd_vma offset;
{
struct bfd_elf_section_data *sec_data;
sec_data = elf_section_data (sec);
if (sec_data->stab_info != NULL)
return _bfd_stab_section_offset
(abfd, &elf_hash_table (info)->stab_info,
sec, &sec_data->stab_info, offset);
return offset;
}

View file

@ -1149,22 +1149,11 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
& elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
@ -1892,9 +1881,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
}
msec = sec;
addend =
_bfd_merged_section_offset (output_bfd, &msec,
elf_section_data (sec)->merge_info,
sym->st_value + addend, (bfd_vma) 0)
_bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
- relocation;
addend += msec->output_section->vma + msec->output_offset;
value = (value & ~ howto->dst_mask) | (addend & howto->dst_mask);

View file

@ -1283,22 +1283,11 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -3949,23 +3949,11 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
are copied into the output file to be resolved at run
time. */
outrel.r_offset = rel->r_offset;
outrel.r_addend = rel->r_addend;
skip = false;
if (elf_section_data (input_section)->stab_info != NULL)
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &htab->elf.stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
skip = (outrel.r_offset == (bfd_vma) -1);
outrel.r_offset += (input_section->output_offset
+ input_section->output_section->vma);

View file

@ -1486,22 +1486,11 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1789,9 +1789,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
msec = sec;
addend =
_bfd_merged_section_offset (output_bfd, &msec,
elf_section_data (sec)->merge_info,
sym->st_value + addend, (bfd_vma) 0)
_bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
- relocation;
addend += msec->output_section->vma + msec->output_offset;
bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
@ -2009,19 +2007,11 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
off = (_bfd_stab_section_offset
(output_bfd, htab->elf.stab_info, input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1680,22 +1680,11 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -6358,29 +6358,10 @@ mips_elf_create_dynamic_relocation (output_bfd, info, rel, h, sec,
< sreloc->_raw_size);
skip = false;
/* We begin by assuming that the offset for the dynamic relocation
is the same as for the original relocation. We'll adjust this
later to reflect the correct output offsets. */
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
/* Except that in a stab section things are more complex.
Because we compress stab information, the offset given in the
relocation may not be the one we want; we must let the stabs
machinery tell us the offset. */
outrel.r_offset
= (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
/* If we didn't need the relocation at all, this value will be
-1. */
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
/* If we've decided to skip this relocation, just output an empty
record. Note that R_MIPS_NONE == 0, so that this call to memset

View file

@ -3210,22 +3210,11 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1891,19 +1891,11 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
off = (_bfd_stab_section_offset
(output_bfd, htab->elf.stab_info, input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -3101,9 +3101,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
msec = sec;
addend =
_bfd_merged_section_offset (output_bfd, &msec,
elf_section_data (sec)->merge_info,
sym->st_value + addend, (bfd_vma) 0)
_bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
- relocation;
addend += msec->output_section->vma + msec->output_offset;
bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
@ -3284,22 +3282,11 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1448,22 +1448,11 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -3534,7 +3534,6 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
case R_ALPHA_REFQUAD:
{
Elf_Internal_Rela outrel;
boolean skip;
/* Careful here to remember RELATIVE relocations for global
variables for symbolic shared objects. */
@ -3569,25 +3568,10 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section,
BFD_ASSERT(srel != NULL);
}
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
if (! skip)
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset != (bfd_vma) -1)
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
else

View file

@ -3494,20 +3494,11 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, htab->elf.stab_info, input_section,
&elf_section_data (input_section)->stab_info,
offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1891,18 +1891,11 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
off = (_bfd_stab_section_offset
(output_bfd, htab->elf.stab_info, input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -2184,21 +2184,11 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rel->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rel->r_offset));
if (off == MINUS_ONE)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rel->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -1473,21 +1473,11 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section,
skip = false;
if (elf_section_data (input_section)->stab_info == NULL)
outrel.r_offset = rela->r_offset;
else
{
bfd_vma off;
off = (_bfd_stab_section_offset
(output_bfd, &elf_hash_table (info)->stab_info,
input_section,
&elf_section_data (input_section)->stab_info,
rela->r_offset));
if (off == (bfd_vma) -1)
skip = true;
outrel.r_offset = off;
}
outrel.r_offset =
_bfd_elf_section_offset (output_bfd, info, input_section,
rela->r_offset);
if (outrel.r_offset == (bfd_vma) -1)
skip = true;
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);

View file

@ -3014,33 +3014,19 @@ elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type,
{
Elf_Internal_Rela outrel;
outrel.r_offset = (sec->output_section->vma
+ sec->output_offset
+ offset);
offset += sec->output_section->vma + sec->output_offset;
BFD_ASSERT (dynindx != -1);
outrel.r_info = ELFNN_R_INFO (dynindx, type);
outrel.r_addend = addend;
if (elf_section_data (sec)->stab_info != NULL)
outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset);
if (outrel.r_offset == (bfd_vma) -1)
{
/* This may be NULL for linker-generated relocations, as it is
inconvenient to pass all the bits around. And this shouldn't
happen. */
BFD_ASSERT (info != NULL);
offset = (_bfd_stab_section_offset
(abfd, &elf_hash_table (info)->stab_info, sec,
&elf_section_data (sec)->stab_info, offset));
if (offset == (bfd_vma) -1)
{
/* Run for the hills. We shouldn't be outputting a relocation
for this. So do what everyone else does and output a no-op. */
outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE);
outrel.r_addend = 0;
offset = 0;
}
outrel.r_offset = offset;
/* Run for the hills. We shouldn't be outputting a relocation
for this. So do what everyone else does and output a no-op. */
outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE);
outrel.r_addend = 0;
outrel.r_offset = 0;
}
bfd_elfNN_swap_reloca_out (abfd, &outrel,