This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add CodeModel attribute to the DefinedAtom class
ClosedPublic

Authored by atanasyan on Nov 12 2014, 2:23 PM.

Details

Summary

MIPS ELF symbols might contain some additional MIPS-specific flags in the st_other field besides visibility ones. These flags indicate code properties like microMIPS / MIPS16 encoding, position independent code etc. We need to transfer the flags from input objects to the output linked file to write them into the symbol table, adjust symbols addresses etc.

I add new attribute CodeModel to the DefinedAtom class to hold target specific flag and to get over YAML/Native format conversion barrier. Other architectures/targets can extend CodeModel enumeration by their own flags.

MIPS specific part of this patch adds support for STO_MIPS_MICROMIPS flag. This flag marks microMIPS symbols. Such symbol should:

  • Has STO_MIPS_MICROMIPS in the corresponding .symtab record.
  • Has adjusted (odd) address in the corresponding .symtab and .dynsym records.

Diff Detail

Event Timeline

atanasyan updated this revision to Diff 16115.Nov 12 2014, 2:23 PM
atanasyan retitled this revision from to [ELF] Add CodeModel attribute to the DefinedAtom class.
atanasyan updated this object.
atanasyan edited the test plan for this revision. (Show Details)
atanasyan added reviewers: shankarke, ruiu, kledzik.
atanasyan added a project: lld.
atanasyan added a subscriber: Unknown Object (MLST).
kledzik edited edge metadata.Nov 12 2014, 2:30 PM

The common code looks good to me.

I did notice that you parse the st_other to get all four MIPS code models, but when building a symbol table only two models are handled. Does that mean running ld -r on a .o file will lose model info?

ruiu accepted this revision.Nov 12 2014, 2:37 PM
ruiu edited edge metadata.

LGTM but please address Nick's comment before submitting.

lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
82

nit: is this what clang-format formatted?

This revision is now accepted and ready to land.Nov 12 2014, 2:37 PM

I plan to implement microMIPS (pic and non-pic) code model support soon. That is why I handle codeMipsMicro and codeMipsMicroPIC flags and postpone processing of codeMips16.

shankarke accepted this revision.Nov 12 2014, 3:08 PM
shankarke edited edge metadata.
atanasyan added inline comments.Nov 12 2014, 9:53 PM
lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h
82

Yes, it looks strange a bit but it is result of the clang-format.

atanasyan closed this revision.Nov 12 2014, 11:08 PM

Thanks for review.

Closed by commit rL221864