This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Allow target to configure ELF header flags in the output file
ClosedPublic

Authored by atanasyan on Dec 16 2015, 9:27 AM.

Details

Summary

The patch configure ELF header flags for MIPS target. For now the flags are hard coded. In fact they depends on ELF flags of input object files and selected emulation.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 43018.Dec 16 2015, 9:27 AM
atanasyan retitled this revision from to [ELF] Allow target to configure ELF header flags in the output file.
atanasyan updated this object.
atanasyan added reviewers: ruiu, rafael.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: llvm-commits.
ruiu added inline comments.Dec 16 2015, 9:30 AM
ELF/Target.cpp
1257–1261 ↗(On Diff #43018)

Instead of assigning a value to ELFFlags member, can you move this code to getELFFlags and return a new value without assignment?

atanasyan added inline comments.Dec 16 2015, 9:32 AM
ELF/Target.cpp
1257–1261 ↗(On Diff #43018)

Do you suggest to make the getELFFlags virtual or put if (Config->EMachine == EM_MIPS) into it?

ruiu added inline comments.Dec 16 2015, 9:34 AM
ELF/Target.cpp
1257–1261 ↗(On Diff #43018)

I have no strong preference, but maybe virtual?

ruiu added inline comments.Dec 16 2015, 10:53 AM
ELF/Target.cpp
1257–1261 ↗(On Diff #43018)

On second thought, this doesn't seem to have to belong this file. This can be written in Writer.cpp as a non-member function. Maybe that's better?

atanasyan updated this revision to Diff 43100.Dec 16 2015, 10:38 PM

Simplify the code. Use a static function to get ELF flags. For now it is a good enough solution.

ruiu accepted this revision.Dec 18 2015, 3:29 PM
ruiu edited edge metadata.

LGTM with a nit.

ELF/Writer.cpp
1009–1017

Can you return early?

if (Config->EMachine != EM_MIPS)
  return 0;
uint32_t V = EF_MIPS_ABI_O32 | ...;
if (Config->Shared)
  return V | EF_MIPS_PIC;
return V;
This revision is now accepted and ready to land.Dec 18 2015, 3:29 PM
This revision was automatically updated to reflect the committed changes.