This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add NMAGIC/OMAGIC support
ClosedPublic

Authored by shankarke on Jun 12 2013, 3:31 PM.

Details

Reviewers
ruiu
Bigcheese
Summary

This adds NMAGIC/OMAGIC support to lld ELF.

Diff Detail

Event Timeline

ruiu added inline comments.Jun 12 2013, 4:10 PM
include/lld/ReaderWriter/ELFTargetInfo.h
42

Please add a prefix ("MAGIC_" or something) to enum constants. DEFAULT seems a bit confusing in particular.

lib/ReaderWriter/ELF/Chunk.h
83

In what situation it can be unknown?

lib/ReaderWriter/ELF/Reader.cpp
109

We need a better diagnostics here.

lib/ReaderWriter/ELF/SegmentChunks.h
433

This condition appears three times. Let's make it a separate function.

Thanks for the review.

include/lld/ReaderWriter/ELFTargetInfo.h
42

Ok

lib/ReaderWriter/ELF/Chunk.h
83

I will make it pure virtual

lib/ReaderWriter/ELF/Reader.cpp
109

Will change to better error code.

lib/ReaderWriter/ELF/SegmentChunks.h
433

Ok

shankarke updated this revision to Unknown Object (????).Jun 12 2013, 9:53 PM

Updated with Ruiu's comments.

shankarke added inline comments.Jun 12 2013, 9:58 PM
lib/ReaderWriter/ELF/Reader.cpp
109

Couldnt find a better error code. Once we have the diagnostics infrastructure, we should report this properly.

ruiu accepted this revision.Jun 12 2013, 10:33 PM

Just curious, is there any real need for NMAGIC and OMAGIC? My understanding about them is they are used in old Unixes and designed to be compact on disk by overlapping segments in one page. I'm wondering what I'd use these formats for.

Its still a supported feature in the other linkers including gold, that are available. Some platforms use this to reduce the amount of virtual address space for a process by merging text/data together.

Bigcheese added inline comments.Jun 13 2013, 1:30 PM
include/lld/ReaderWriter/ELFTargetInfo.h
39–42

Use enum class.

49

This should be the enum type.

shankarke added inline comments.Jun 14 2013, 8:54 AM
include/lld/ReaderWriter/ELFTargetInfo.h
49

Ok.

shankarke updated this revision to Unknown Object (????).Jun 14 2013, 8:54 AM

Address comments from Bigcheese.

Eugene.Zelenko closed this revision.Oct 5 2016, 1:33 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL184055.