[PATCH] D40147: [MIPS] Handle cross-mode (regular <-> microMIPS) jumps
Simon Atanasyan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 13:24:33 PST 2017
atanasyan created this revision.
atanasyan added a project: lld.
Herald added subscribers: arichardson, sdardis, emaste.
The patch solves two tasks:
1. MIPS ABI allows to mix regular and microMIPS code and perform cross-mode jumps. Linker needs to detect such cases and replace jump/branch instructions by their cross-mode equivalents.
2. Other tools like dunamic linkers need to recognize cases when dynamic table entries, e_entry field of an ELF header etc point to microMIPS symbol. Linker should provide such information.
The first task is implemented in the `MIPS<ELFT>::relocateOne()` method. New routine `fixupCrossModeJump` detects ISA mode change, checks and replaces an instruction.
The main problem is how to recognize that relocation target is microMIPS symbol. For absolute and section symbols compiler or assembler set the less-significant bit of the symbol's value or sum of the symbol's value and addend. And this bit signals to linker about microMIPS code. For global symbols compiler cannot do the same trick because other tools like, for example, disassembler want to know an actual position of the symbol. So compiler sets STO_MIPS_MICROMIPS flag in the `st_other` field.
In `MIPS<ELFT>::relocateOne()` method we have a symbol's value only and cannot access any symbol's attributes. To pass type of the global symbol (regular/microMIPS) to that routine as well as other places where we write a symbol value as-is (.dynamic section, `Elf_Ehdr::e_entry` field etc) we set when necessary a less-significant bit in the `getSymVA` function.
Repository:
rL LLVM
https://reviews.llvm.org/D40147
Files:
ELF/Arch/Mips.cpp
ELF/Symbols.cpp
ELF/SyntheticSections.cpp
ELF/Thunks.cpp
test/ELF/mips-micro-bad-cross-calls.s
test/ELF/mips-micro-cross-calls.s
test/ELF/mips-micro-plt.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40147.123236.patch
Type: text/x-patch
Size: 12228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171116/22a61c99/attachment.bin>
More information about the llvm-commits
mailing list