fix segment fault for plt on mips64.
Details
- Reviewers
• espindola ruiu atanasyan - Commits
- rZORGb49b85d537e0: [mips] Fix ld instruction in PLT entries on MIPS64
rZORG2d0e83afc969: [mips] Fix ld instruction in PLT entries on MIPS64
rGb49b85d537e0: [mips] Fix ld instruction in PLT entries on MIPS64
rG2d0e83afc969: [mips] Fix ld instruction in PLT entries on MIPS64
rG3bdb81c26da6: [mips] Fix ld instruction in PLT entries on MIPS64
rL360187: [mips] Fix ld instruction in PLT entries on MIPS64
rLLD360187: [mips] Fix ld instruction in PLT entries on MIPS64
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 31493 Build 31492: arc lint + arc unit
Event Timeline
while using clang+lld+flto compiling on mips64-linux platform,
the compiling is ok, but generating mips64-assemble-code is wrong wthin @plt,
If runnging the mips64-elf executable file will emit a segment fault because the codes within section of .plt are not for mips64.
for example,
Dump of assembler code for function __cxa_atexit@plt:
0x0000000000e11d20 <+0>: lui t3,0x189 0x0000000000e11d24 <+4>:** lw t9,-31944(t3)** 0x0000000000e11d28 <+8>: jr t9 0x0000000000e11d2c <+12>: ** addiu t8,t3,-31944**
End of assembler dump.
Dump of assembler code for function clock_gettime@plt:
0x0000000000e11d30 <+0>: lui t3,0x189 0x0000000000e11d34 <+4>:** lw t9,-31936(t3)** 0x0000000000e11d38 <+8>: jr t9 0x0000000000e11d3c <+12>: **addiu t8,t3,-31936**
End of assembler dump.
The correct codes are:
Dump of assembler code for function __cxa_atexit@plt:
0x0000000000e11d20 <+0>: lui t3,0x189 0x0000000000e11d24 <+4>: ld t9,-31944(t3) 0x0000000000e11d28 <+8>: jr t9 0x0000000000e11d2c <+12>: daddiu t8,t3,-31944
End of assembler dump.
Dump of assembler code for function clock_gettime@plt:
0x0000000000e11d30 <+0>: lui t3,0x189 0x0000000000e11d34 <+4>: ld t9,-31936(t3) 0x0000000000e11d38 <+8>: jr t9 0x0000000000e11d3c <+12>: daddiu t8,t3,-31936
End of assembler dump.
Good catch, thanks. BTW on what OS do you get this problem? PLT records on MIPS 64-bit code are not widely used.
Please add test case for the patch. Probably we can split the lld/test/ELF/mips-26-n32-n64.s into N32 and N64 variants.
lld/ELF/Arch/Mips.cpp | ||
---|---|---|
334–338 | Remove curly brackets for this branch or add them for both ones. | |
340–344 | Ditto |
My OS is mips64el-fedora desktop-PC.
Our company is loongson, a CPU-processor-design company in China.
And our company are now pupulating the mips64el-linux-desktop in China quickly.
Please add test case for the patch. Probably we can split the lld/test/ELF/mips-26-n32-n64.s into N32 and N64 variants.
I will upload later.
Please add test case for the patch. Probably we can split the lld/test/ELF/mips-26-n32-n64.s into N32 and N64 variants.
How to distinguish between the N32 and N64 abi by llvm-mc if we split lld/test/ELF/mips-26-n32-n64.s into two files ?
Such as my OS-mips64el, if we split lld/test/ELF/mips-26-n32-n64.s into mips-26-n32.s and mips-26-n64.s ,
we compile the two files using llvm-mc, they are both N64 becaause there is no args liking -mabi=n32 for llvm-mc.
I think the title line should be more descriptive, e.g. "[mips] Fix ld instruction in PLT entries on MIPS64"....
Remove curly brackets for this branch or add them for both ones.