Skip to content

Commit f9c6b90

Browse files
committed
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.
1 parent e17aaa3 commit f9c6b90

13 files changed

Lines changed: 433 additions & 109 deletions

File tree

‎bfd/ChangeLog‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2013-10-30 Alan Modra <amodra@gmail.com>
2+
3+
* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
4+
BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
5+
BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
6+
* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
7+
Make all _HA and _HI relocs report signed overflow.
8+
(ppc64_elf_reloc_type_lookup): Handle new relocs.
9+
(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
10+
(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
11+
(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
12+
R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
13+
R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
14+
* libbfd.h: Regenerate.
15+
* bfd-in2.h: Regenerate.
16+
117
2013-10-29 Roland McGrath <mcgrathr@google.com>
218

319
* elf64-x86-64.c (elf_x86_64_nacl_plt0_entry): Correct 9-byte nop

‎bfd/bfd-in2.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,6 +3223,8 @@ instruction. */
32233223
BFD_RELOC_PPC64_TOC16_LO_DS,
32243224
BFD_RELOC_PPC64_PLTGOT16_DS,
32253225
BFD_RELOC_PPC64_PLTGOT16_LO_DS,
3226+
BFD_RELOC_PPC64_ADDR16_HIGH,
3227+
BFD_RELOC_PPC64_ADDR16_HIGHA,
32263228

32273229
/* PowerPC and PowerPC64 thread-local storage relocations. */
32283230
BFD_RELOC_PPC_TLS,
@@ -3267,6 +3269,10 @@ instruction. */
32673269
BFD_RELOC_PPC64_DTPREL16_HIGHERA,
32683270
BFD_RELOC_PPC64_DTPREL16_HIGHEST,
32693271
BFD_RELOC_PPC64_DTPREL16_HIGHESTA,
3272+
BFD_RELOC_PPC64_TPREL16_HIGH,
3273+
BFD_RELOC_PPC64_TPREL16_HIGHA,
3274+
BFD_RELOC_PPC64_DTPREL16_HIGH,
3275+
BFD_RELOC_PPC64_DTPREL16_HIGHA,
32703276

32713277
/* IBM 370/390 relocations */
32723278
BFD_RELOC_I370_D12,

0 commit comments

Comments
 (0)