From: Will Newton Date: Tue, 28 May 2013 16:00:36 +0000 (+0000) Subject: bfd/efl32-arm.c: Fix handling of IRELATIVE relocs. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f36889e238007e7779858edd43a1fb79d289fbb4;p=thirdparty%2Fbinutils-gdb.git bfd/efl32-arm.c: Fix handling of IRELATIVE relocs. bfd/ChangeLog: 2013-05-28 Will Newton * elf32-arm.c (elf32_arm_populate_plt_entry): Call elf32_arm_add_dynreloc when emitting R_ARM_IRELATIVE relocs. ld/testsuite/ChangeLog: 2013-05-28 Will Newton * ld-arm/arm-elf.exp: Add IFUNC test 17. * ld-arm/ifunc-17.dd: New file. * ld-arm/ifunc-17.gd: Likewise. * ld-arm/ifunc-17.rd: Likewise. * ld-arm/ifunc-17.s: Likweise. * ld-arm/ifunc-1.rd: Reorder relocs to match linker output. * ld-arm/ifunc-2.rd: Likewise. * ld-arm/ifunc-5.rd: Likewise. * ld-arm/ifunc-6.rd: Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2074173340b..45d1919a616 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2013-05-28 Will Newton + + * elf32-arm.c (elf32_arm_populate_plt_entry): Call + elf32_arm_add_dynreloc when emitting R_ARM_IRELATIVE relocs. + 2013-04-24 Roland McGrath * elf32-arm.c (elf32_arm_allocate_plt_entry): If HTAB->nacl_p, diff --git a/bfd/doc/bfd.info b/bfd/doc/bfd.info index ce01eda3b08..7e11660d771 100644 --- a/bfd/doc/bfd.info +++ b/bfd/doc/bfd.info @@ -1,4 +1,4 @@ -This is bfd.info, produced by makeinfo version 4.8 from bfd.texinfo. +This is bfd.info, produced by makeinfo version 4.13 from bfd.texinfo. INFO-DIR-SECTION Software development START-INFO-DIR-ENTRY @@ -8434,9 +8434,9 @@ The linker proper will call the `_bfd_link_add_symbols' entry point for each object file or archive which is to be linked (typically these are the files named on the command line, but some may also come from the linker script). The entry point is responsible for examining the file. -For an object file, BFD must add any relevant symbol information to -the hash table. For an archive, BFD must determine which elements of -the archive should be used and adding them to the link. +For an object file, BFD must add any relevant symbol information to the +hash table. For an archive, BFD must determine which elements of the +archive should be used and adding them to the link. The a.out version of this entry point is `NAME(aout,link_add_symbols)'. @@ -12742,67 +12742,67 @@ BFD Index  Tag Table: -Node: Top1089 -Node: Overview1428 -Node: History2479 -Node: How It Works3425 -Node: What BFD Version 2 Can Do4968 -Node: BFD information loss6283 -Node: Canonical format8815 -Node: BFD front end13187 -Node: Memory Usage47553 -Node: Initialization48781 -Node: Sections49240 -Node: Section Input49723 -Node: Section Output51088 -Node: typedef asection53574 -Node: section prototypes78781 -Node: Symbols89038 -Node: Reading Symbols90633 -Node: Writing Symbols91740 -Node: Mini Symbols93481 -Node: typedef asymbol94455 -Node: symbol handling functions100514 -Node: Archives105856 -Node: Formats109582 -Node: Relocations112530 -Node: typedef arelent113257 -Node: howto manager128893 -Node: Core Files227332 -Node: Targets229370 -Node: bfd_target231340 -Node: Architectures254562 -Node: Opening and Closing280438 -Node: Internal291957 -Node: File Caching298302 -Node: Linker Functions300216 -Node: Creating a Linker Hash Table301889 -Node: Adding Symbols to the Hash Table303627 -Node: Differing file formats304527 -Node: Adding symbols from an object file306252 -Node: Adding symbols from an archive308403 -Node: Performing the Final Link311332 -Node: Information provided by the linker312574 -Node: Relocating the section contents313728 -Node: Writing the symbol table315479 -Node: Hash Tables319865 -Node: Creating and Freeing a Hash Table321063 -Node: Looking Up or Entering a String322313 -Node: Traversing a Hash Table323566 -Node: Deriving a New Hash Table Type324355 -Node: Define the Derived Structures325421 -Node: Write the Derived Creation Routine326502 -Node: Write Other Derived Routines329126 -Node: BFD back ends330441 -Node: What to Put Where330711 -Node: aout330891 -Node: coff337209 -Node: elf365642 -Node: mmo366043 -Node: File layout366971 -Node: Symbol-table372618 -Node: mmo section mapping376387 -Node: GNU Free Documentation License380039 -Node: BFD Index405122 +Node: Top1090 +Node: Overview1429 +Node: History2480 +Node: How It Works3426 +Node: What BFD Version 2 Can Do4969 +Node: BFD information loss6284 +Node: Canonical format8816 +Node: BFD front end13188 +Node: Memory Usage47554 +Node: Initialization48782 +Node: Sections49241 +Node: Section Input49724 +Node: Section Output51089 +Node: typedef asection53575 +Node: section prototypes78782 +Node: Symbols89039 +Node: Reading Symbols90634 +Node: Writing Symbols91741 +Node: Mini Symbols93482 +Node: typedef asymbol94456 +Node: symbol handling functions100515 +Node: Archives105857 +Node: Formats109583 +Node: Relocations112531 +Node: typedef arelent113258 +Node: howto manager128894 +Node: Core Files227333 +Node: Targets229371 +Node: bfd_target231341 +Node: Architectures254563 +Node: Opening and Closing280439 +Node: Internal291958 +Node: File Caching298303 +Node: Linker Functions300217 +Node: Creating a Linker Hash Table301890 +Node: Adding Symbols to the Hash Table303628 +Node: Differing file formats304528 +Node: Adding symbols from an object file306253 +Node: Adding symbols from an archive308404 +Node: Performing the Final Link311333 +Node: Information provided by the linker312575 +Node: Relocating the section contents313729 +Node: Writing the symbol table315480 +Node: Hash Tables319866 +Node: Creating and Freeing a Hash Table321064 +Node: Looking Up or Entering a String322314 +Node: Traversing a Hash Table323567 +Node: Deriving a New Hash Table Type324356 +Node: Define the Derived Structures325422 +Node: Write the Derived Creation Routine326503 +Node: Write Other Derived Routines329127 +Node: BFD back ends330442 +Node: What to Put Where330712 +Node: aout330892 +Node: coff337210 +Node: elf365643 +Node: mmo366044 +Node: File layout366972 +Node: Symbol-table372619 +Node: mmo section mapping376388 +Node: GNU Free Documentation License380040 +Node: BFD Index405123  End Tag Table diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 22aabc8971f..7e87d707ffe 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -7734,8 +7734,13 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info, sgot->contents + got_offset); } - loc = srel->contents + plt_index * RELOC_SIZE (htab); - SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + if (dynindx == -1) + elf32_arm_add_dynreloc (output_bfd, info, srel, &rel); + else + { + loc = srel->contents + plt_index * RELOC_SIZE (htab); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + } } /* Some relocations map to different relocations depending on the diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 6d516e08a42..4cb34d323da 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2013-05-28 Will Newton + + * ld-arm/arm-elf.exp: Add IFUNC test 17. + * ld-arm/ifunc-17.dd: New file. + * ld-arm/ifunc-17.gd: Likewise. + * ld-arm/ifunc-17.rd: Likewise. + * ld-arm/ifunc-17.s: Likweise. + * ld-arm/ifunc-1.rd: Reorder relocs to match linker output. + * ld-arm/ifunc-2.rd: Likewise. + * ld-arm/ifunc-5.rd: Likewise. + * ld-arm/ifunc-6.rd: Likewise. + 2013-03-05 Alan Modra * ld-scripts/rgn-at6.s, * ld-scripts/rgn-at6.t, * ld-scripts/rgn-at6.d, diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 8e15ffe5087..91b06571dee 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -433,6 +433,11 @@ set armelftests_nonacl { {objdump {-s -j.data -j.got} ifunc-16.gd} {readelf -r ifunc-16.rd}} "ifunc-16"} + {"IFUNC test 17" "-T ifunc-static.ld" "" {ifunc-17.s} + {{objdump -d ifunc-17.dd} + {objdump {-s -j.data -j.got} ifunc-17.gd} + {readelf -r ifunc-17.rd}} + "ifunc-17"} } run_ld_link_tests $armelftests_common diff --git a/ld/testsuite/ld-arm/ifunc-1.rd b/ld/testsuite/ld-arm/ifunc-1.rd index 75e6d700bc0..264412312f6 100644 --- a/ld/testsuite/ld-arm/ifunc-1.rd +++ b/ld/testsuite/ld-arm/ifunc-1.rd @@ -4,5 +4,5 @@ There is no dynamic section in this file\. Relocation section '\.rel\.dyn' at offset 0x8000 contains 3 entries: Offset Info Type Sym\.Value Sym\. Name 0001100c ......a0 R_ARM_IRELATIVE -00011010 ......a0 R_ARM_IRELATIVE 00011014 ......a0 R_ARM_IRELATIVE +00011010 ......a0 R_ARM_IRELATIVE diff --git a/ld/testsuite/ld-arm/ifunc-17.dd b/ld/testsuite/ld-arm/ifunc-17.dd new file mode 100644 index 00000000000..ee5cd050aa3 --- /dev/null +++ b/ld/testsuite/ld-arm/ifunc-17.dd @@ -0,0 +1,25 @@ + +.* + + +Disassembly of section \.iplt: + +00009000 <.iplt>: +#------------------------------------------------------------------------------ +#------ appfunc1's .iplt entry +#------------------------------------------------------------------------------ + 9000: e28fc600 add ip, pc, #0, 12 + 9004: e28cca08 add ip, ip, #8, 20 ; 0x8000 + 9008: e5bcf004 ldr pc, \[ip, #4\]! + +Disassembly of section \.text: + +0000a000 : + a000: 46f7 mov pc, lr + +0000a002 : + a002: 46f7 mov pc, lr + +0000a004 <_start>: + a004: f7fe effc blx 9000 + a008: 00000010 \.word 0x00000010 diff --git a/ld/testsuite/ld-arm/ifunc-17.gd b/ld/testsuite/ld-arm/ifunc-17.gd new file mode 100644 index 00000000000..dadfc9eeb5e --- /dev/null +++ b/ld/testsuite/ld-arm/ifunc-17.gd @@ -0,0 +1,10 @@ + +.* + +Contents of section \.got: +#------------------------------------------------------------------------------ +#------ 0001100c: 0xa001 (appfunc1) +#------ 00011010: 0xa003 (appfunc2) +#------------------------------------------------------------------------------ + 11000 00000000 00000000 00000000 01a00000 .* + 11010 03a00000 .* diff --git a/ld/testsuite/ld-arm/ifunc-17.rd b/ld/testsuite/ld-arm/ifunc-17.rd new file mode 100644 index 00000000000..b167f4529d5 --- /dev/null +++ b/ld/testsuite/ld-arm/ifunc-17.rd @@ -0,0 +1,5 @@ + +Relocation section '\.rel\.dyn' at offset 0x8000 contains 2 entries: + Offset Info Type Sym\.Value Sym\. Name +0001100c ......a0 R_ARM_IRELATIVE +00011010 ......a0 R_ARM_IRELATIVE diff --git a/ld/testsuite/ld-arm/ifunc-17.s b/ld/testsuite/ld-arm/ifunc-17.s new file mode 100644 index 00000000000..75c4c568448 --- /dev/null +++ b/ld/testsuite/ld-arm/ifunc-17.s @@ -0,0 +1,24 @@ + .syntax unified + .arch armv6t2 + + .global appfunc1 + .type appfunc1,%gnu_indirect_function + .thumb +appfunc1: + mov pc,lr + .size appfunc1,.-appfunc1 + + .global appfunc2 + .type appfunc2,%gnu_indirect_function + .thumb +appfunc2: + mov pc,lr + .size appfunc2,.-appfunc2 + + .global _start + .type _start,%function + .thumb +_start: + bl appfunc1(PLT) + .word appfunc2(GOT) + .size _start,.-_start diff --git a/ld/testsuite/ld-arm/ifunc-2.rd b/ld/testsuite/ld-arm/ifunc-2.rd index 92b000a86f5..7bbabf421f3 100644 --- a/ld/testsuite/ld-arm/ifunc-2.rd +++ b/ld/testsuite/ld-arm/ifunc-2.rd @@ -5,9 +5,9 @@ Relocation section '\.rel\.dyn' at offset 0x8000 contains 8 entries: Offset Info Type Sym\.Value Sym\. Name 0001100c ......a0 R_ARM_IRELATIVE 00011010 ......a0 R_ARM_IRELATIVE +00011020 ......a0 R_ARM_IRELATIVE +00011028 ......a0 R_ARM_IRELATIVE 00011014 ......a0 R_ARM_IRELATIVE 00011018 ......a0 R_ARM_IRELATIVE 0001101c ......a0 R_ARM_IRELATIVE -00011020 ......a0 R_ARM_IRELATIVE 00011024 ......a0 R_ARM_IRELATIVE -00011028 ......a0 R_ARM_IRELATIVE diff --git a/ld/testsuite/ld-arm/ifunc-5.rd b/ld/testsuite/ld-arm/ifunc-5.rd index 75e6d700bc0..264412312f6 100644 --- a/ld/testsuite/ld-arm/ifunc-5.rd +++ b/ld/testsuite/ld-arm/ifunc-5.rd @@ -4,5 +4,5 @@ There is no dynamic section in this file\. Relocation section '\.rel\.dyn' at offset 0x8000 contains 3 entries: Offset Info Type Sym\.Value Sym\. Name 0001100c ......a0 R_ARM_IRELATIVE -00011010 ......a0 R_ARM_IRELATIVE 00011014 ......a0 R_ARM_IRELATIVE +00011010 ......a0 R_ARM_IRELATIVE diff --git a/ld/testsuite/ld-arm/ifunc-6.rd b/ld/testsuite/ld-arm/ifunc-6.rd index 0fbfec5905d..04c18a926f6 100644 --- a/ld/testsuite/ld-arm/ifunc-6.rd +++ b/ld/testsuite/ld-arm/ifunc-6.rd @@ -3,7 +3,7 @@ There is no dynamic section in this file\. Relocation section '\.rel\.dyn' at offset 0x8000 contains 4 entries: Offset Info Type Sym\.Value Sym\. Name -0001100c ......a0 R_ARM_IRELATIVE +00011018 ......a0 R_ARM_IRELATIVE 00011010 ......a0 R_ARM_IRELATIVE +0001100c ......a0 R_ARM_IRELATIVE 00011014 ......a0 R_ARM_IRELATIVE -00011018 ......a0 R_ARM_IRELATIVE