This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Fix crash in LLD when linking code that needs PIC thunks
ClosedPublic

Authored by arichardson on Nov 17 2017, 5:54 AM.

Details

Summary

The bug triggers when the following conditions are met:

  • A thunk is created in a given input section S
  • A linker script is specified
  • There is at least one matcher in the linker script .text section output that does not match any of the sections in the input files, before the matcher that matches section S.

The issue was found when linking the FreeBSD kernel for MIPS when built
with -fPIC. Patch by Alfredo Mazzinghi.

Diff Detail

Repository
rL LLVM

Event Timeline

arichardson created this revision.Nov 17 2017, 5:54 AM

(Adding my Linaro email address as a reviewer) My apologies for missing that case. This looks good to me as by definition we can't find our target section in an empty InputSectionDescription. Will be worth seeing if Rui has any style comments.

arichardson added inline comments.Nov 17 2017, 8:53 AM
test/ELF/linkerscript/thunk-gen-mips.s
41 ↗(On Diff #123324)

I will add this newline before comitting.

ruiu accepted this revision.Nov 20 2017, 3:26 AM

LGTM

This revision is now accepted and ready to land.Nov 20 2017, 3:26 AM
This revision was automatically updated to reflect the committed changes.