forked from Imagelibrary/binutils-gdb
* elf32-i386.c (elf_i386_relocate_section): If -Bsymbolic, when
copying relocs into a shared object, treat a defined global symbol as a local symbol. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-mips.c (mips_elf_relocate_section): Likewise. * elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
This commit is contained in:
@@ -22,9 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#include "bfdlink.h"
|
||||
#include "libbfd.h"
|
||||
#include "elf-bfd.h"
|
||||
/* start-sanitize-v8plus */
|
||||
#include "elf/sparc.h"
|
||||
/* end-sanitize-v8plus */
|
||||
|
||||
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
@@ -47,15 +45,11 @@ static boolean elf32_sparc_finish_dynamic_symbol
|
||||
Elf_Internal_Sym *));
|
||||
static boolean elf32_sparc_finish_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
/* start-sanitize-v8plus */
|
||||
static boolean elf32_sparc_set_private_flags PARAMS ((bfd *, flagword));
|
||||
static boolean elf32_sparc_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
static boolean elf32_sparc_merge_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
static boolean elf32_sparc_object_p
|
||||
PARAMS ((bfd *));
|
||||
static void elf32_sparc_final_write_processing
|
||||
PARAMS ((bfd *, boolean));
|
||||
/* end-sanitize-v8plus */
|
||||
|
||||
enum reloc_type
|
||||
{
|
||||
@@ -914,6 +908,9 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
|| (h->elf_link_hash_flags
|
||||
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|
||||
|| (info->shared
|
||||
&& (! info->symbolic
|
||||
|| (h->elf_link_hash_flags
|
||||
& ELF_LINK_HASH_DEF_REGULAR) == 0)
|
||||
&& (input_section->flags & SEC_ALLOC) != 0
|
||||
&& (r_type == R_SPARC_8
|
||||
|| r_type == R_SPARC_16
|
||||
@@ -1131,7 +1128,10 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
outrel.r_offset = (rel->r_offset
|
||||
+ input_section->output_section->vma
|
||||
+ input_section->output_offset);
|
||||
if (h != NULL)
|
||||
if (h != NULL
|
||||
&& (! info->symbolic
|
||||
|| (h->elf_link_hash_flags
|
||||
& ELF_LINK_HASH_DEF_REGULAR) == 0))
|
||||
{
|
||||
BFD_ASSERT (h->dynindx != -1);
|
||||
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
|
||||
@@ -1148,8 +1148,15 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
{
|
||||
long indx;
|
||||
|
||||
sym = local_syms + r_symndx;
|
||||
sec = local_sections[r_symndx];
|
||||
if (h == NULL)
|
||||
sec = local_sections[r_symndx];
|
||||
else
|
||||
{
|
||||
BFD_ASSERT (h->root.type == bfd_link_hash_defined
|
||||
|| (h->root.type
|
||||
== bfd_link_hash_defweak));
|
||||
sec = h->root.u.def.section;
|
||||
}
|
||||
if (sec != NULL && bfd_is_abs_section (sec))
|
||||
indx = 0;
|
||||
else if (sec == NULL || sec->owner == NULL)
|
||||
@@ -1491,45 +1498,13 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
|
||||
|
||||
return true;
|
||||
}
|
||||
/* start-sanitize-v8plus */
|
||||
|
||||
/* Function to set e_flags. */
|
||||
/* Functions for dealing with the e_flags field.
|
||||
|
||||
static boolean
|
||||
elf32_sparc_set_private_flags (abfd, flags)
|
||||
bfd *abfd;
|
||||
flagword flags;
|
||||
{
|
||||
/* Once the flags have been set, you (apparently) can't change them. */
|
||||
BFD_ASSERT (!elf_flags_init (abfd)
|
||||
|| elf_elfheader (abfd)->e_flags == flags);
|
||||
|
||||
elf_elfheader (abfd)->e_flags = flags;
|
||||
elf_flags_init (abfd) = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Copy backend specific data from one object module to another. */
|
||||
|
||||
static boolean
|
||||
elf32_sparc_copy_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
/* This function is selected based on the input vector. We only
|
||||
want to copy information over if the output BFD also uses Elf
|
||||
format. */
|
||||
if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
||||
return true;
|
||||
|
||||
/* Once the flags have been set, you (apparently) can't change them. */
|
||||
BFD_ASSERT (!elf_flags_init (obfd)
|
||||
|| elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
|
||||
|
||||
elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
|
||||
elf_flags_init (obfd) = true;
|
||||
return true;
|
||||
}
|
||||
We don't define set_private_flags or copy_private_bfd_data because
|
||||
the only currently defined values are based on the bfd mach number,
|
||||
so we use the latter instead and defer setting e_flags until the
|
||||
file is written out. */
|
||||
|
||||
/* Merge backend specific data from an object file to the output
|
||||
object file when linking. */
|
||||
@@ -1539,8 +1514,6 @@ elf32_sparc_merge_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
flagword old_flags;
|
||||
flagword new_flags;
|
||||
boolean error;
|
||||
|
||||
/* This function is selected based on the input vector. We only
|
||||
@@ -1551,6 +1524,13 @@ elf32_sparc_merge_private_bfd_data (ibfd, obfd)
|
||||
|
||||
error = false;
|
||||
|
||||
#if 0
|
||||
/* ??? The native linker doesn't do this so we can't (otherwise gcc would
|
||||
have to know which linker is being used). Instead, the native linker
|
||||
bumps up the architecture level when it has to. However, I still think
|
||||
warnings like these are good, so it would be nice to have them turned on
|
||||
by some option. */
|
||||
|
||||
/* If the output machine is normal sparc, we can't allow v9 input files. */
|
||||
if (bfd_get_mach (obfd) == bfd_mach_sparc
|
||||
&& (bfd_get_mach (ibfd) == bfd_mach_sparc_v8plus
|
||||
@@ -1570,30 +1550,17 @@ elf32_sparc_merge_private_bfd_data (ibfd, obfd)
|
||||
("%s: compiled for a v8plusa system and target is v8plus",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
|
||||
new_flags = elf_elfheader (ibfd)->e_flags;
|
||||
old_flags = elf_elfheader (obfd)->e_flags;
|
||||
if (!elf_flags_init (obfd)) /* First call, no flags set */
|
||||
#else
|
||||
if (bfd_get_mach (ibfd) >= bfd_mach_sparc_v9)
|
||||
{
|
||||
elf_flags_init (obfd) = true;
|
||||
elf_elfheader (obfd)->e_flags = new_flags;
|
||||
}
|
||||
else if (new_flags == old_flags) /* Compatible flags are ok */
|
||||
;
|
||||
else /* Potentially incompatible flags */
|
||||
{
|
||||
new_flags &= ~ (EF_SPARC_32PLUS | EF_SPARC_SUN_US1);
|
||||
old_flags &= ~ (EF_SPARC_32PLUS | EF_SPARC_SUN_US1);
|
||||
|
||||
/* Warn about any other mismatches */
|
||||
if (new_flags != old_flags)
|
||||
{
|
||||
error = true;
|
||||
(*_bfd_error_handler)
|
||||
("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
|
||||
bfd_get_filename (ibfd), (long) new_flags, (long) old_flags);
|
||||
}
|
||||
error = true;
|
||||
(*_bfd_error_handler)
|
||||
("%s: compiled for a 64 bit system and target is 32 bit",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
else if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))
|
||||
bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));
|
||||
#endif
|
||||
|
||||
if (error)
|
||||
{
|
||||
@@ -1611,7 +1578,16 @@ elf32_sparc_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
if (elf_elfheader (abfd)->e_machine == EM_SPARC32PLUS)
|
||||
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc_v8plus);
|
||||
{
|
||||
if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
|
||||
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
|
||||
bfd_mach_sparc_v8plusa);
|
||||
else if (elf_elfheader (abfd)->e_flags & EF_SPARC_32PLUS)
|
||||
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc,
|
||||
bfd_mach_sparc_v8plus);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, bfd_mach_sparc);
|
||||
}
|
||||
@@ -1624,24 +1600,30 @@ elf32_sparc_final_write_processing (abfd, linker)
|
||||
bfd *abfd;
|
||||
boolean linker;
|
||||
{
|
||||
if (bfd_get_mach (abfd) == bfd_mach_sparc_v8plus)
|
||||
switch (bfd_get_mach (abfd))
|
||||
{
|
||||
case bfd_mach_sparc :
|
||||
break; /* nothing to do */
|
||||
case bfd_mach_sparc_v8plus :
|
||||
elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
|
||||
#if 0 /* FIXME: Not sure how to handle EF_SPARC_32PLUS_US1 */
|
||||
elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
|
||||
#endif
|
||||
elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS;
|
||||
break;
|
||||
case bfd_mach_sparc_v8plusa :
|
||||
elf_elfheader (abfd)->e_machine = EM_SPARC32PLUS;
|
||||
elf_elfheader (abfd)->e_flags &=~ EF_SPARC_32PLUS_MASK;
|
||||
elf_elfheader (abfd)->e_flags |= EF_SPARC_32PLUS | EF_SPARC_SUN_US1;
|
||||
break;
|
||||
default :
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
/* end-sanitize-v8plus */
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf32_sparc_vec
|
||||
#define TARGET_BIG_NAME "elf32-sparc"
|
||||
#define ELF_ARCH bfd_arch_sparc
|
||||
#define ELF_MACHINE_CODE EM_SPARC
|
||||
/* start-sanitize-v8plus */
|
||||
#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
|
||||
/* end-sanitize-v8plus */
|
||||
#define ELF_MAXPAGESIZE 0x10000
|
||||
#define elf_backend_create_dynamic_sections \
|
||||
_bfd_elf_create_dynamic_sections
|
||||
@@ -1655,16 +1637,11 @@ elf32_sparc_final_write_processing (abfd, linker)
|
||||
elf32_sparc_finish_dynamic_symbol
|
||||
#define elf_backend_finish_dynamic_sections \
|
||||
elf32_sparc_finish_dynamic_sections
|
||||
/* start-sanitize-v8plus */
|
||||
#define bfd_elf32_bfd_set_private_flags elf32_sparc_set_private_flags
|
||||
#define bfd_elf32_bfd_copy_private_bfd_data \
|
||||
elf32_sparc_copy_private_bfd_data
|
||||
#define bfd_elf32_bfd_merge_private_bfd_data \
|
||||
elf32_sparc_merge_private_bfd_data
|
||||
#define elf_backend_object_p elf32_sparc_object_p
|
||||
#define elf_backend_final_write_processing \
|
||||
elf32_sparc_final_write_processing
|
||||
/* end-sanitize-v8plus */
|
||||
#define elf_backend_want_got_plt 0
|
||||
#define elf_backend_plt_readonly 0
|
||||
#define elf_backend_want_plt_sym 1
|
||||
|
||||
Reference in New Issue
Block a user