x86_64 PIC fix
Jan Hubicka
jh@suse.cz
Tue Feb 6 15:51:00 GMT 2001
Hi
This patch fixes name of GOTPCREL relocation in elf64 and makes gas to
cope with this type of relocation.
If no one will cry I will install it tomorrow (or day later) to the both
release and mainline branches.
Honza
Wed Feb 7 00:45:20 CET 2001 Jan Hubicka <jh@suse.cz>
* elf64-x86-64.c (x86_64_elf_howto): Fix name of R_X86_64_GOTPCREL.
* tc-i386.c (i386_displacement): Fix handling of
BFD_RELOC_X86_64_GOTPCREL.
(i386_validate_fix): Likewise.
Index: src/bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 elf64-x86-64.c
*** elf64-x86-64.c 2001/01/23 20:27:53 1.4
--- elf64-x86-64.c 2001/02/06 23:41:12
*************** static reloc_howto_type x86_64_elf_howto
*** 45,51 ****
HOWTO(R_X86_64_GLOB_DAT, 0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_GLOB_DAT",false,MINUS_ONE ,MINUS_ONE ,false),
HOWTO(R_X86_64_RELATIVE ,0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_RELATIVE",false,MINUS_ONE ,MINUS_ONE ,false),
HOWTO(R_X86_64_JUMP_SLOT,0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_JUMP_SLOT",false,MINUS_ONE,MINUS_ONE ,false),
! HOWTO(R_X86_64_GOTPCREL, 0,4,32,true, 0,complain_overflow_signed ,0, "R_X86_64_PCREL", false,0xffffffff,0xffffffff,true),
HOWTO(R_X86_64_32, 0,4,32,false,0,complain_overflow_unsigned,0, "R_X86_64_32", false,0xffffffff,0xffffffff,false),
HOWTO(R_X86_64_32S, 0,4,32,false,0,complain_overflow_signed, 0, "R_X86_64_32S", false,0xffffffff,0xffffffff,false),
HOWTO(R_X86_64_16, 0,1,16,false,0,complain_overflow_bitfield,0, "R_X86_64_16", false,0xffff ,0xffff, false),
--- 45,51 ----
HOWTO(R_X86_64_GLOB_DAT, 0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_GLOB_DAT",false,MINUS_ONE ,MINUS_ONE ,false),
HOWTO(R_X86_64_RELATIVE ,0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_RELATIVE",false,MINUS_ONE ,MINUS_ONE ,false),
HOWTO(R_X86_64_JUMP_SLOT,0,4,64,false,0,complain_overflow_bitfield,0,"R_X86_64_JUMP_SLOT",false,MINUS_ONE,MINUS_ONE ,false),
! HOWTO(R_X86_64_GOTPCREL, 0,4,32,true, 0,complain_overflow_signed ,0, "R_X86_64_GOTPCREL",false,0xffffffff,0xffffffff,true),
HOWTO(R_X86_64_32, 0,4,32,false,0,complain_overflow_unsigned,0, "R_X86_64_32", false,0xffffffff,0xffffffff,false),
HOWTO(R_X86_64_32S, 0,4,32,false,0,complain_overflow_signed, 0, "R_X86_64_32S", false,0xffffffff,0xffffffff,false),
HOWTO(R_X86_64_16, 0,1,16,false,0,complain_overflow_bitfield,0, "R_X86_64_16", false,0xffff ,0xffff, false),
Index: src/gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.83
diff -c -3 -p -r1.83 tc-i386.c
*** tc-i386.c 2001/01/17 23:41:35 1.83
--- tc-i386.c 2001/02/06 23:41:18
*************** i386_displacement (disp_start, disp_end)
*** 3436,3442 ****
assert (exp->X_op == O_symbol);
exp->X_op = O_subtract;
exp->X_op_symbol = GOT_symbol;
! i.disp_reloc[this_operand] = BFD_RELOC_32;
}
#endif
--- 3436,3445 ----
assert (exp->X_op == O_symbol);
exp->X_op = O_subtract;
exp->X_op_symbol = GOT_symbol;
! if (i.disp_reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL)
! i.disp_reloc[this_operand] = BFD_RELOC_32_PCREL;
! else
! i.disp_reloc[this_operand] = BFD_RELOC_32;
}
#endif
*************** i386_validate_fix (fixp)
*** 4600,4608 ****
if (fixp->fx_subsy && fixp->fx_subsy == GOT_symbol)
{
/* GOTOFF relocation are nonsense in 64bit mode. */
! if (flag_code == CODE_64BIT)
! abort ();
! fixp->fx_r_type = BFD_RELOC_386_GOTOFF;
fixp->fx_subsy = 0;
}
}
--- 4603,4620 ----
if (fixp->fx_subsy && fixp->fx_subsy == GOT_symbol)
{
/* GOTOFF relocation are nonsense in 64bit mode. */
! if (fixp->fx_r_type == BFD_RELOC_32_PCREL)
! {
! if (flag_code != CODE_64BIT)
! abort ();
! fixp->fx_r_type = BFD_RELOC_X86_64_GOTPCREL;
! }
! else
! {
! if (flag_code == CODE_64BIT)
! abort ();
! fixp->fx_r_type = BFD_RELOC_386_GOTOFF;
! }
fixp->fx_subsy = 0;
}
}
More information about the Binutils
mailing list