This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello! The ELF standard says that STN_UNDEF (symbol index zero, the undefined symbol index) is to be marked as SHN_UNDEF, undefined symbol. There is one exception however: during relocations processing, a relocation against STN_UNDEF shall be treated as a symbol value of zero. For example on ARM, the bl instruction does a PC-relative jump, so to jump to an absolute value of 0x10000, ``bl 0x10000'' has to keep its relocation until the final linking is done, to be converted to the proper PC-relative offset. $ cat < ~/sgxx/issue8612/bl_ABS.s bl 0x10000 $ "$PWD"_install/bin/*-as -o bl_ABS.o ~/sgxx/issue8612/bl_ABS.s $ "$PWD"_install/bin/*-readelf -r bl_ABS.o Relocation section '.rel.text' at offset 0x25c contains 1 entries: Offset Info Type Sym.Value Sym. Name 00000000 0000001c R_ARM_CALL This info value translates to relocation type 28 (R_ARM_CALL) against symbol index zero (STN_UNDEF). On 2010-09-24 00:12, Alan Modra wrote: > On Thu, Sep 23, 2010 at 05:37:01PM +0200, Thomas Schwinge wrote: >> $ "$PWD"_install/bin/*-ld -o bl_ABS bl_ABS.o >> /scratch/thomas/binutils/HEAD_build_arm-none-eabi_install/bin/arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000 >> bl_ABS.o:(.text+0x0): undefined reference to `no symbol' > > ARM fails because the arm backend specifically checks for undefined > local symbols. I'd say the arm backend check needs fixing (or > removing) rather than changing the common elflink code. Here is a patch to fix this issue in the ARM backend. There are no regressions with a --target=arm-none-eabi config. bfd/ 2010-09-24 Thomas Schwinge <thomas@codesourcery.com> * elf32-arm.c (elf32_arm_final_link_relocate) (elf32_arm_relocate_section): Handle relocations against STN_UNDEF. Index: bfd/elf32-arm.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-arm.c,v retrieving revision 1.241 diff -u -p -r1.241 elf32-arm.c --- bfd/elf32-arm.c 26 Aug 2010 10:32:26 -0000 1.241 +++ bfd/elf32-arm.c 24 Sep 2010 11:16:45 -0000 @@ -7224,12 +7224,12 @@ elf32_arm_final_link_relocate (reloc_how /* A branch to an undefined weak symbol is turned into a jump to the next instruction unless a PLT entry will be created. - Do the same for local undefined symbols. + Do the same for local undefined symbols (but not for STN_UNDEF). The jump to the next instruction is optimized as a NOP depending on the architecture. */ if (h ? (h->root.type == bfd_link_hash_undefweak && !(splt != NULL && h->plt.offset != (bfd_vma) -1)) - : bfd_is_und_section (sym_sec)) + : r_symndx != STN_UNDEF && bfd_is_und_section (sym_sec)) { value = (bfd_get_32 (input_bfd, hit_data) & 0xf0000000); @@ -8903,9 +8903,11 @@ elf32_arm_relocate_section (bfd * undefined symbol. This is a daft object file, but we should at least do something about it. V4BX & NONE relocations do not use the symbol and are explicitly - allowed to use the undefined symbol, so allow those. */ + allowed to use the undefined symbol, so allow those. + Likewise for relocations against STN_UNDEF. */ if (r_type != R_ARM_V4BX && r_type != R_ARM_NONE + && r_symndx != STN_UNDEF && bfd_is_und_section (sec) && ELF_ST_BIND (sym->st_info) != STB_WEAK) { Success with patched BFD: $ "$PWD"_install/bin/*-ld -o bl_ABS bl_ABS.o /scratch/thomas/binutils/HEAD_build_arm-none-eabi_install/bin/arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000 $ "$PWD"_install/bin/*-readelf -r bl_ABS There are no relocations in this file. $ "$PWD"_install/bin/*-objdump -dr bl_ABS bl_ABS: file format elf32-littlearm Disassembly of section .text: 00008000 <__data_start-0x8004>: 8000: eb001ffe bl 10000 <__bss_end__-0x4> Regards, Thomas
Attachment:
pgp00000.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |