[ELF][MIPS] N32 ABI support
authorSimon Atanasyan <simon@atanasyan.com>
Sat, 5 Nov 2016 22:58:01 +0000 (22:58 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Sat, 5 Nov 2016 22:58:01 +0000 (22:58 +0000)
commit9e0297b8bc1eafbd1eb845c740727abab44afa2f
treeac93458d1e2a2f938e969f4085aff5dc4c1bb7ea
parent8c6a5aaf1575a079e95e67729c486bee2f1f3f1f
[ELF][MIPS] N32 ABI support

In short the patch introduces support for linking object file conform
MIPS N32 ABI [1]. This ABI is similar to N64 ABI but uses 32-bit
pointer size.

The most non-trivial requirement of this ABI is one more relocation
packing format. N64 ABI puts multiple relocation type into the single
relocation record. The N32 ABI uses series of successive relocations
with the same offset for this purpose. In this patch, new function
`mergeMipsN32RelTypes` handle this case and "convert" N32 relocation to
the N64 relocation so the rest of the code keep unchanged.

For now, linker does not support series of relocations applied to sections
without SHF_ALLOC bit. Probably later I will add the support or insert
some sort of assert into the `relocateNonAlloc` routine to catch this
case.

[1] ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/MIPS-N32-ABI-Handbook.pdf

Differential revision: https://reviews.llvm.org/D26298

llvm-svn: 286052
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Mips.cpp
lld/ELF/Relocations.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/Target.cpp
lld/ELF/Writer.h
lld/test/ELF/Inputs/mips-n32-rels.o [new file with mode: 0644]
lld/test/ELF/mips-elf-flags-err.s
lld/test/ELF/mips-n32-emul.s [new file with mode: 0644]
lld/test/ELF/mips-n32-rels.s [new file with mode: 0644]