* elf32-i386.c: Don't include "elf/i386.h".
(X86_PCREL_TYPE_P): Removed.
(X86_SIZE_TYPE_P): Likewise.
(elf_i386_check_relocs): Pass false to NEED_DYNAMIC_RELOCATION_P.
(elf_i386_relocate_section): Pass false to
GENERATE_DYNAMIC_RELOCATION_P and COPY_INPUT_RELOC_P.
* elf64-x86-64.c: Don't include "elf/x86-64.h".
(X86_PCREL_TYPE_P): Removed.
(X86_SIZE_TYPE_P): Likewise.
(elf_x86_64_check_relocs): Pass true to NEED_DYNAMIC_RELOCATION_P
and X86_PCREL_TYPE_P.
(elf_x86_64_relocate_section): Pass true to X86_PCREL_TYPE_P,
X86_SIZE_TYPE_P, GENERATE_DYNAMIC_RELOCATION_P and
COPY_INPUT_RELOC_P.
* elfxx-x86.c: Don't include "elf/i386.h" nor "elf/x86-64.h".
* elfxx-x86.h (X86_64_PCREL_TYPE_P): New.
(I386_PCREL_TYPE_P): Likewise.
(X86_PCREL_TYPE_P): Likewise.
(X86_64_SIZE_TYPE_P): Likewise.
(I386_SIZE_TYPE_P): Likewise.
(X86_SIZE_TYPE_P): Likewise.
(NEED_DYNAMIC_RELOCATION_P): Add IS_X86_64 and pass it to
X86_PCREL_TYPE_P.
(COPY_INPUT_RELOC_P): Likewise.
(GENERATE_DYNAMIC_RELOCATION_P): Add IS_X86_64, pass it to
X86_PCREL_TYPE_P and X86_SIZE_TYPE_P.
/* 386 uses REL relocations instead of RELA. */
#define USE_REL 1
-#include "elf/i386.h"
-
static reloc_howto_type elf_howto_table[]=
{
HOWTO(R_386_NONE, 0, 3, 0, false, 0, complain_overflow_dont,
};
-#define X86_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
-
-#define X86_SIZE_TYPE_P(TYPE) ((TYPE) == R_386_SIZE32)
-
#ifdef DEBUG_GEN_RELOC
#define TRACE(str) \
fprintf (stderr, "i386 bfd reloc lookup %d (%s)\n", code, str)
size_reloc = false;
do_size:
if (!no_dynreloc
- && NEED_DYNAMIC_RELOCATION_P (info, false, h, sec, r_type,
- R_386_32))
+ && NEED_DYNAMIC_RELOCATION_P (false, info, false, h, sec,
+ r_type, R_386_32))
{
struct elf_dyn_relocs *p;
struct elf_dyn_relocs **head;
|| is_vxworks_tls)
break;
- if (GENERATE_DYNAMIC_RELOCATION_P (info, eh, r_type, sec,
- false, resolved_to_zero,
+ if (GENERATE_DYNAMIC_RELOCATION_P (false, info, eh, r_type,
+ sec, false,
+ resolved_to_zero,
(r_type == R_386_PC32)))
{
Elf_Internal_Rela outrel;
if (skip)
memset (&outrel, 0, sizeof outrel);
- else if (COPY_INPUT_RELOC_P (info, h, r_type))
+ else if (COPY_INPUT_RELOC_P (false, info, h, r_type))
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
else
{
#include "libiberty.h"
#include "opcode/i386.h"
-#include "elf/x86-64.h"
#ifdef CORE_HEADER
#include <stdarg.h>
false)
};
-#define X86_PCREL_TYPE_P(TYPE) \
- ( ((TYPE) == R_X86_64_PC8) \
- || ((TYPE) == R_X86_64_PC16) \
- || ((TYPE) == R_X86_64_PC32) \
- || ((TYPE) == R_X86_64_PC32_BND) \
- || ((TYPE) == R_X86_64_PC64))
-
-#define X86_SIZE_TYPE_P(TYPE) \
- ((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64)
-
/* Map BFD relocs to the x86_64 elf relocs. */
struct elf_reloc_map
{
size_reloc = false;
do_size:
if (!no_dynreloc
- && NEED_DYNAMIC_RELOCATION_P (info, true, h, sec, r_type,
+ && NEED_DYNAMIC_RELOCATION_P (true, info, true, h, sec,
+ r_type,
htab->pointer_r_type))
{
struct elf_dyn_relocs *p;
p->count += 1;
/* Count size relocation as PC-relative relocation. */
- if (X86_PCREL_TYPE_P (r_type) || size_reloc)
+ if (X86_PCREL_TYPE_P (true, r_type) || size_reloc)
p->pc_count += 1;
}
break;
|| eh->needs_copy
|| (h->root.type
== bfd_link_hash_undefined))
- && (X86_PCREL_TYPE_P (r_type)
- || X86_SIZE_TYPE_P (r_type)));
+ && (X86_PCREL_TYPE_P (true, r_type)
+ || X86_SIZE_TYPE_P (true,
+ r_type)));
- if (GENERATE_DYNAMIC_RELOCATION_P (info, eh, r_type, sec,
+ if (GENERATE_DYNAMIC_RELOCATION_P (true, info, eh, r_type, sec,
need_copy_reloc_in_pie,
resolved_to_zero, false))
{
if (skip)
memset (&outrel, 0, sizeof outrel);
- else if (COPY_INPUT_RELOC_P (info, h, r_type))
+ else if (COPY_INPUT_RELOC_P (true, info, h, r_type))
{
outrel.r_info = htab->r_info (h->dynindx, r_type);
outrel.r_addend = rel->r_addend;
#include "elfxx-x86.h"
#include "elf-vxworks.h"
#include "objalloc.h"
-#include "elf/i386.h"
-#include "elf/x86-64.h"
/* The name of the dynamic interpreter. This is put in the .interp
section. */
#include "elf-bfd.h"
#include "hashtab.h"
#include "elf-linker-x86.h"
+#include "elf/i386.h"
+#include "elf/x86-64.h"
+
+#define X86_64_PCREL_TYPE_P(TYPE) \
+ ((TYPE) == R_X86_64_PC8 \
+ || (TYPE) == R_X86_64_PC16 \
+ || (TYPE) == R_X86_64_PC32 \
+ || (TYPE) == R_X86_64_PC32_BND \
+ || (TYPE) == R_X86_64_PC64)
+#define I386_PCREL_TYPE_P(TYPE) ((TYPE) == R_386_PC32)
+#define X86_PCREL_TYPE_P(IS_X86_64, TYPE) \
+ ((IS_X86_64) ? X86_64_PCREL_TYPE_P (TYPE) : I386_PCREL_TYPE_P (TYPE))
+
+#define X86_64_SIZE_TYPE_P(TYPE) \
+ ((TYPE) == R_X86_64_SIZE32 || (TYPE) == R_X86_64_SIZE64)
+#define I386_SIZE_TYPE_P(TYPE) ((TYPE) == R_386_SIZE32)
+#define X86_SIZE_TYPE_P(IS_X86_64, TYPE) \
+ ((IS_X86_64) ? X86_64_SIZE_TYPE_P(TYPE) : I386_SIZE_TYPE_P (TYPE))
#define PLT_CIE_LENGTH 20
#define PLT_FDE_LENGTH 36
We also need to generate dynamic pointer relocation against
STT_GNU_IFUNC symbol in the non-code section. */
-#define NEED_DYNAMIC_RELOCATION_P(INFO, PCREL_PLT, H, SEC, R_TYPE, \
- POINTER_TYPE) \
+#define NEED_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, PCREL_PLT, H, SEC, \
+ R_TYPE, POINTER_TYPE) \
((bfd_link_pic (INFO) \
- && (! X86_PCREL_TYPE_P (R_TYPE) \
+ && (! X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
|| ((H) != NULL \
&& (! (bfd_link_pie (INFO) \
|| SYMBOLIC_BIND ((INFO), (H))) \
when PC32_RELOC is TRUE. Undefined weak symbol is bound locally
when PIC is false. Don't generate dynamic relocations against
non-preemptible absolute symbol. */
-#define GENERATE_DYNAMIC_RELOCATION_P(INFO, EH, R_TYPE, SEC, \
- NEED_COPY_RELOC_IN_PIE, \
+#define GENERATE_DYNAMIC_RELOCATION_P(IS_X86_64, INFO, EH, R_TYPE, \
+ SEC, NEED_COPY_RELOC_IN_PIE, \
RESOLVED_TO_ZERO, PC32_RELOC) \
((bfd_link_pic (INFO) \
&& !(bfd_is_abs_section (SEC) \
|| ((ELF_ST_VISIBILITY ((EH)->elf.other) == STV_DEFAULT \
&& (!(RESOLVED_TO_ZERO) || PC32_RELOC)) \
|| (EH)->elf.root.type != bfd_link_hash_undefweak)) \
- && ((!X86_PCREL_TYPE_P (R_TYPE) && !X86_SIZE_TYPE_P (R_TYPE)) \
+ && ((!X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
+ && !X86_SIZE_TYPE_P (IS_X86_64, R_TYPE)) \
|| ! SYMBOL_CALLS_LOCAL ((INFO), \
(struct elf_link_hash_entry *) (EH)))) \
|| (ELIMINATE_COPY_RELOCS \
/* TRUE if this input relocation should be copied to output. H->dynindx
may be -1 if this symbol was marked to become local. */
-#define COPY_INPUT_RELOC_P(INFO, H, R_TYPE) \
+#define COPY_INPUT_RELOC_P(IS_X86_64, INFO, H, R_TYPE) \
((H) != NULL \
&& (H)->dynindx != -1 \
- && (X86_PCREL_TYPE_P (R_TYPE) \
+ && (X86_PCREL_TYPE_P (IS_X86_64, R_TYPE) \
|| !(bfd_link_executable (INFO) || SYMBOLIC_BIND ((INFO), (H))) \
|| !(H)->def_regular))