diff options
author | Alan Modra <amodra@gmail.com> | 2013-10-29 16:53:25 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2013-10-30 13:33:15 +1030 |
commit | f9c6b9078c54ea0f018b673e2ff128e61a0aa666 (patch) | |
tree | d930fc55471caaf4b267600004868317e1d5e3d0 /include/elf | |
parent | e17aaa33b10ed1d047a01cefb5547844c0597836 (diff) | |
download | gdb-f9c6b9078c54ea0f018b673e2ff128e61a0aa666.zip gdb-f9c6b9078c54ea0f018b673e2ff128e61a0aa666.tar.gz gdb-f9c6b9078c54ea0f018b673e2ff128e61a0aa666.tar.bz2 |
Report overflow on PowerPC64 @h and @ha relocations.
This changes the behaviour of @h and @ha on PowerPC64 to report errors
on 32-bit overflow. The motivation for this change is that on
PowerPC64, most uses of @h and @ha modifiers and their corresponding
relocations are to build up 32-bit offsets. We'd like to know when
such offsets overflow. Only rarely do people use @h or @ha with the
high 32-bit modifiers to build a 64-bit constant. Those uses will now
need to use two new modifiers, @high and @higha, if the constant isn't
known at assembly time. For now, we won't report overflow at assembly
time..
This also fixes an error when applying some of the HIGHER and HIGHEST
relocations.
include/elf/
* ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New.
(IS_PPC64_TLS_RELOC): Match new tls relocs.
bfd/
* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
Make all _HA and _HI relocs report signed overflow.
(ppc64_elf_reloc_type_lookup): Handle new relocs.
(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
gas/
* config/tc-ppc.c (SEX16): Don't mask.
(REPORT_OVERFLOW_HI): Define as zero.
(ppc_elf_suffix): Support @high, @higha, @dtprel@high, @dtprel@higha,
@tprel@high, and @tprel@higha modifiers.
(md_assemble): Ignore X_unsigned when applying 16-bit insn fields.
Add (disabled) code to check @h and @ha reloc overflow for powerpc64.
Handle new relocs.
(md_apply_fix): Similarly.
elfcpp/
* powerpc.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA,
R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA,
R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): Define.
gold/
* powerpc.cc (Target_powerpc::Scan::check_non_pic): Handle new relocs.
(Target_powerpc::Scan::global, local): Likewise.
(Target_powerpc::Relocate::relocate): Likewise. Check for overflow
on all ppc64 @h and @ha relocs.
Diffstat (limited to 'include/elf')
-rw-r--r-- | include/elf/ChangeLog | 7 | ||||
-rw-r--r-- | include/elf/ppc64.h | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index c2577e8..fae0bf8 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,10 @@ +2013-10-30 Alan Modra <amodra@gmail.com> + + * ppc64.h (R_PPC64_ADDR16_HIGH, R_PPC64_ADDR16_HIGHA, + R_PPC64_TPREL16_HIGH, R_PPC64_TPREL16_HIGHA, + R_PPC64_DTPREL16_HIGH, R_PPC64_DTPREL16_HIGHA): New. + (IS_PPC64_TLS_RELOC): Match new tls relocs. + 2013-10-14 Chao-ying Fu <Chao-ying.Fu@imgtec.com> * mips.h (enum): Add Tag_GNU_MIPS_ABI_MSA. diff --git a/include/elf/ppc64.h b/include/elf/ppc64.h index f1c80f1..221786f 100644 --- a/include/elf/ppc64.h +++ b/include/elf/ppc64.h @@ -141,6 +141,14 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type) RELOC_NUMBER (R_PPC64_TLSLD, 108) RELOC_NUMBER (R_PPC64_TOCSAVE, 109) +/* Added when HA and HI relocs were changed to report overflows. */ + RELOC_NUMBER (R_PPC64_ADDR16_HIGH, 110) + RELOC_NUMBER (R_PPC64_ADDR16_HIGHA, 111) + RELOC_NUMBER (R_PPC64_TPREL16_HIGH, 112) + RELOC_NUMBER (R_PPC64_TPREL16_HIGHA, 113) + RELOC_NUMBER (R_PPC64_DTPREL16_HIGH, 114) + RELOC_NUMBER (R_PPC64_DTPREL16_HIGHA, 115) + #ifndef RELOC_MACROS_GEN_FUNC /* Fake relocation only used internally by ld. */ RELOC_NUMBER (R_PPC64_LO_DS_OPT, 128) @@ -161,8 +169,9 @@ START_RELOC_NUMBERS (elf_ppc64_reloc_type) END_RELOC_NUMBERS (R_PPC64_max) -#define IS_PPC64_TLS_RELOC(R) \ - ((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA) +#define IS_PPC64_TLS_RELOC(R) \ + (((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA) \ + || ((R) >= R_PPC64_TPREL16_HIGH && (R) <= R_PPC64_DTPREL16_HIGHA)) /* Specify the start of the .glink section. */ #define DT_PPC64_GLINK DT_LOPROC |