This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Support linking of PIE for MIPS
ClosedPublic

Authored by atanasyan on Feb 15 2018, 11:38 AM.

Details

Summary

MIPS ABI requires creation of the MIPS_RLD_MAP dynamic tag for non-PIE executables only and MIPS_RLD_MAP_REL tag for both PIE and non-PIE executables. The patch skips definition of the MIPS_RLD_MAP for PIE files and defines MIPS_RLD_MAP_REL.

The MIPS_RLD_MAP_REL tag stores the offset to the .rld_map section relative to the address of the tag itself.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

atanasyan created this revision.Feb 15 2018, 11:38 AM
grimar added a subscriber: grimar.Feb 20 2018, 11:45 PM
grimar added inline comments.
ELF/SyntheticSections.cpp
1027

I think new member (like addTagRelSec) would be better here.
Because logic controlled with parameter by default here looks too specific and
code looks like 2 methods were merged into one.

atanasyan updated this revision to Diff 135203.Feb 21 2018, 1:44 AM
  • Using a separate function to create a dynamic table entry with a relative address of a section

I can verify that without this patch pie executables crash inside the FreeBSD (CheriBSD) RTLD when processing DT_MIPS_RLD_MAP and with it they work.

I can verify that without this patch pie executables crash inside the FreeBSD (CheriBSD) RTLD when processing DT_MIPS_RLD_MAP and with it they work.

Thanks for the testing.

Ping? Any objections to commit this patch?

espindola edited reviewers, added: espindola; removed: rafael.Mar 15 2018, 8:36 AM

Ping? This patch got the last comment one month ago.

Rebased against the trunk.

grimar added inline comments.Mar 28 2018, 4:15 AM
test/ELF/mips-dynamic.s
51–79

I think that this test case, for example, does not really check that
DT_MIPS_RLD_MAP is not emitted for PIE.

Problem is that *-NEXT and/or *-NOT are not used and check tags are
mixed, what is a bit hard to read.

I would suggest explicitly testing DynamicSection twice, one time with
use of PIE/PIE-NEXT and the second time with NOPIE/NOPIE-NEXT
to show which tags are produced for each case.

Explicitly testing DynamicSection content for PIE and no-PIE cases.

atanasyan added inline comments.Mar 29 2018, 12:03 AM
test/ELF/mips-dynamic.s
51–79

I would suggest explicitly testing DynamicSection twice

Good point. Thanks.

grimar accepted this revision.Mar 29 2018, 1:57 AM

This LGTM. But please wait for the final accept from Rui/Rafael.

This revision is now accepted and ready to land.Mar 29 2018, 1:57 AM

Thanks for review.

Rui, Rafael: I'm going to commit the patch by the end of the next week if I do not get any negative comments.

This revision was automatically updated to reflect the committed changes.