diff options
| author | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2015-04-27 13:55:14 +0000 |
|---|---|---|
| committer | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2015-04-27 13:55:14 +0000 |
| commit | 6bf4da02c13673bfd34f447a4b8a68905e05dea7 (patch) | |
| tree | 622154d1c87b18b89503b6b9a98ffa9c5ab11764 /lld/lib/ReaderWriter/ELF/ELFFile.cpp | |
| parent | 7a6b18783f771d1cf721f87a11ddf65da0491ed4 (diff) | |
| download | bcm5719-llvm-6bf4da02c13673bfd34f447a4b8a68905e05dea7.tar.gz bcm5719-llvm-6bf4da02c13673bfd34f447a4b8a68905e05dea7.zip | |
ELF/ARM: Ignore R_ARM_V4BX for ARMv4 but allow linking
This patch allow the ARM relocation R_ARM_V4BX to be processed by lld,
although it is not really handled in the static relocation code. The
relocation is in the form:
Relocation section '.rel.text' at offset 0x428 contains 4 entries:
Offset Info Type Sym.Value Sym. Name
00000014 00000028 R_ARM_V4BX
Meaning it does have a direct target, but rather references to an absolute
section *ABS* (in this exemple to the .text segment itself). It makes the
target Atom after file parse to not have a associated pointer and thus
generating a derrefence NULL point in ELFFile<ELFT>::findAtom. Current
approach is just ignore and return nullptr in such cases.
The problem relies that default GCC configuration
for arm-linux-gnueabi{hf} emits the relocation for the asm:
--
.syntax unified
.arm
.p2align 2
.type fn, %function
fn:
ldr r3, .LGOT
ldr r2, .LGOT+4
.LPIC:
add r3, pc, r3
ldr r2, [r3, r2]
cmp r2, #0
bxeq lr
b __start__
.LGOT:
.word _GLOBAL_OFFSET_TABLE_-(.LPIC+8)
.word __start__(GOT)
--
But only with the option -march=armv4 (which is the default GCC configuration).
For arm5 and forward the relocation is not created. This a special relocation
(defined miscellaneous for ARM) that instruct the linker to replace the bx
instruction into a mov. GNU linker has some options related to which substitution
it can create for such cases.
With this patch I can dynamically link an application against a GLIBC
arm-linux-gnueabi system configured with default GCC.
llvm-svn: 235880
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/ELFFile.cpp')
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFFile.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.cpp b/lld/lib/ReaderWriter/ELF/ELFFile.cpp index ab2ec605687..57c25038eda 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFFile.cpp @@ -38,6 +38,11 @@ Atom *ELFFile<ELFT>::findAtom(const Elf_Sym *sourceSym, const Elf_Sym *targetSym) { // Return the atom for targetSym if we can do so. Atom *target = _symbolToAtomMapping.lookup(targetSym); + if (!target) + // Some realocations (R_ARM_V4BX) do not have a defined + // target. For this cases make it points to itself. + target = _symbolToAtomMapping.lookup(sourceSym); + if (target->definition() != Atom::definitionRegular) return target; Atom::Scope scope = llvm::cast<DefinedAtom>(target)->scope(); |

