This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Handle GOT entries for all non-local symbols uniformly
AbandonedPublic

Authored by atanasyan on Apr 25 2016, 1:57 PM.

Details

Reviewers
ruiu
rafael
Summary

The patch assigns 'kind' to each GOT entry. Now they are MipsLocal, MipsGlobal and Regular. That allows to create entries for all non-local symbols and handle them uniformly. From the other side we have to sort GOT entries before writing .got section accordingly to their types.

The main motivations for this patch is preparation for support MIPS TLS relocations. It might sound like a joke but for GOT entries related to TLS relocations MIPS ABI uses almost regular approach with creation of dynamic relocations for each GOT enty etc. But we need to separate these 'regular' TLS related entries from MIPS specific local/global parts of GOT. ABI declare simple solution - all TLS related entries allocated at the end of GOT after local/global parts. To support these scheme, we anyway have to differentiate and sort GOT entries.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 54898.Apr 25 2016, 1:57 PM
atanasyan retitled this revision from to [ELF][MIPS] Handle GOT entries for all non-local symbols uniformly.
atanasyan updated this object.
atanasyan added reviewers: rafael, ruiu.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
zatrazz added inline comments.
ELF/OutputSections.h
141

On my TLS descriptor patch [1], after some discussion I changed the approach of using a vector of vectors to just define the required vectors instead (one for each type). I think using a vector for each type simplifies the code, since it won't require sorting in the finalize method.

[1] http://reviews.llvm.org/D18960

atanasyan added inline comments.Apr 26 2016, 6:31 AM
ELF/OutputSections.h
141

My motivation was to touch non-MIPS code as little as possible. In that case single vector is a good approach. But if MIPS is not the only architecture requires GOT entries "types" I would be happy to escape GOT sorting.

What is the state of your patch?

zatrazz added inline comments.Apr 26 2016, 6:39 AM
ELF/OutputSections.h
141

SImilar to your patch my motivation is to enable current supported TLS but for aarch64. The patch does not really touch any aarch64 specifics bits (I plan to send another patch after this is reviewed), and the ideia is to make possible to use this TLS descriptor code not only to support aarch64, but all architectures that have TLS dsecriptor abi (arm, i386, x86_64, and aarch64).

I got some initial reviews, but currently it requires a thoughtfully one.

atanasyan added inline comments.Apr 28 2016, 7:54 AM
ELF/OutputSections.h
141

I was thinking about using multiple vectors to hold different entries in the GotSection class. In the MIPS case that approach simplifies the finalize method because we do not have to sort the entries. But it makes methods which calculate various GOT indexes really messy. In case of MIPS we need at least three containers: for local entries, for global entries, and for TLS related entries.

atanasyan updated this revision to Diff 55709.Apr 30 2016, 2:52 AM
  • Rebased
rafael edited edge metadata.Apr 30 2016, 8:40 AM

So, with the multiple vector solution, the index computation would still be simple for the non mips case, no? We would still have just

Sym.GotIndex = Entries.size();

Only inside the mips specific code would we have to look at MipsLocal and MipsGlobal entries.

Would you mind giving that a try?

atanasyan abandoned this revision.Jun 13 2016, 9:24 AM