This is an archive of the discontinued LLVM Phabricator instance.

Fix crash when processing relocations in .eh_frame
ClosedPublic

Authored by arichardson on May 30 2017, 5:04 AM.

Details

Summary

This happens when attempting to link shared libraries using exceptions on
MIPS. It requires -z notext because clang generates R_MIPS_64 relocations
inside .eh_frame.
The crash happened because for EhInputSection the OutSec member is null.

Event Timeline

arichardson created this revision.May 30 2017, 5:04 AM
grimar added a subscriber: llvm-commits.
grimar added inline comments.May 30 2017, 5:19 AM
test/ELF/mips64-eh-abs-reloc.s
2

You're missing REQUIRES: mips

4

We do not check what llvm-mc produces in tests for LLD I think.

14

Not sure why do you need to check this. Did executable case crash before this patch ?
Generally I think you just need simplest test that crashed before and do not crash after.

arichardson marked an inline comment as done.
arichardson edited the summary of this revision. (Show Details)

Simplified the test case

arichardson added inline comments.May 30 2017, 5:28 AM
test/ELF/mips64-eh-abs-reloc.s
4

I only have this line here to make sure that there is a R_MIPS_64 relocation in .eh_frame in case llvm-mc changes. I could also change it to use a YAML testcase but to me the assembly version is easier to understand.

14

Only shared lib and -pie executable case would crash before, so I've deleted all but those.

atanasyan accepted this revision.May 30 2017, 5:57 AM

LGTM with the latest fixes.

Just a side note - this patch fix allows linking with the -z notext option. GNU and gold linkers work even without this option. They convert absolute R_MIPS_32/64 relocations against .eh_frame section into relative equivalents.

This revision is now accepted and ready to land.May 30 2017, 5:57 AM
arichardson marked an inline comment as done.May 30 2017, 6:25 AM

I don't have commit access, could you commit for me please?