This is an archive of the discontinued LLVM Phabricator instance.

[ELF][MIPS] Factor out SumVA adjustments into a couple of separate functions. NFC.
ClosedPublic

Authored by atanasyan on Mar 12 2016, 4:06 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 50524.Mar 12 2016, 4:06 AM
atanasyan retitled this revision from to [ELF][MIPS] Factor out SumVA adjustments into a couple of separate functions. NFC..
atanasyan updated this object.
atanasyan added reviewers: ruiu, rafael, grimar.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
grimar edited edge metadata.Mar 12 2016, 8:39 AM

Generally this looks good to me, have few notes though.

ELF/InputSection.cpp
219 ↗(On Diff #50524)

Is that correct ? Originally addend was added:

 SymVA = Out<ELFT>::Got->getMipsLocalFullAddr(Body) + A;
 }
}
else {
 SymVA = Body.getGotVA<ELFT>() + A;
290 ↗(On Diff #50524)

I don't like this place because it has "if (Config->EMachine == EM_MIPS)"
I would do next:

  1. rename static uintX_t getMipsGotVA -> static uintX_t getGotVA
  2. remove uintX_t SymVA argument, but add uintX_t A

and do:

template <class ELFT, class uintX_t>
static uintX_t getGotVA(const SymbolBody &Body, uintX_t A,
                            uint8_t *BufLoc, uint8_t *PairedLoc) {

if (Config->EMachine != EM_MIPS)
 return Body.getGotVA<ELFT>() + A;
...
else if (Target->needsGot(Type, Body)) {
  SymVA = getGotVA<ELFT>(Body, A, BufLoc, PairedLoc);
...
ruiu accepted this revision.Mar 12 2016, 6:23 PM
ruiu edited edge metadata.

Since this is a refactoring patch to split the function, LGTM.

But I really want you and all other people who are working on MIPS to not only add code to the support current MIPS ABI but also make efforts to fix the ABI. Some parts of the ABI are very odd and sometimes even broken (e.g. the mixed endian header field), and supporting it sometimes really complicates stuff (like the paired relocations.)

ELF/InputSection.cpp
290 ↗(On Diff #50524)

I prefer the other way. This function would not have been written if MIPS ABI were not so weird. I want to keep the code in the form that you can ignore all function calls including "mips" if you are not interested in MIPS. If you move that code into the function, you have to jump to that function and read that function only to know that that was basically separated for MIPS oddity.

This revision is now accepted and ready to land.Mar 12 2016, 6:23 PM

Thanks for review.

The oddity of MIPS ABI is obvious to everybody. Probably the ABI will be changed gradually or by release completely new ABI but anyway it is a long process.

ELF/InputSection.cpp
219 ↗(On Diff #50524)

It is correct for 32-bit MIPS because in that case we use REL format and have to extract addend from the buffer insider the relocateOne routine. The A is always zero. But I will return + A expressions before commit the patch to escape unnecessary changes.

This revision was automatically updated to reflect the committed changes.