[lld] r193662 - [ELF] Implement minimal support for .eh_frame_hdr.
Shankar Easwaran
shankare at codeaurora.org
Tue Oct 29 17:50:03 PDT 2013
Cool!
I think generation of the eh_frame_hdr is decided by --eh-frame-hdr flag
isnt it ?
And GNU_EH_FRAME segment is only relevant when you are only using GNU
tools ?
Have few review comments below.
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=193662&r1=193661&r2=193662&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Tue Oct 29 19:02:04 2013
@@ -105,6 +105,7 @@ protected:
LLD_UNIQUE_BUMP_PTR(StringTable<ELFT>) _strtab;
LLD_UNIQUE_BUMP_PTR(StringTable<ELFT>) _shstrtab;
LLD_UNIQUE_BUMP_PTR(SectionHeader<ELFT>) _shdrtab;
+ LLD_UNIQUE_BUMP_PTR(EHFrameHeader<ELFT>) _ehFrameHeader;
/// \name Dynamic sections.
/// @{
LLD_UNIQUE_BUMP_PTR(DynamicTable<ELFT>) _dynamicTable;
@@ -267,6 +268,15 @@ template <class ELFT> void OutputELFWrit
_symtab->setStringSection(_strtab.get());
_layout->addSection(_shdrtab.get());
+ for (auto sec : _layout->sections()) {
+ if (sec->name() != ".eh_frame")
+ continue;
+ _ehFrameHeader.reset(new (_alloc) EHFrameHeader<ELFT>(
+ _context, ".eh_frame_hdr", DefaultLayout<ELFT>::ORDER_EH_FRAMEHDR));
+ _layout->addSection(_ehFrameHeader.get());
+ break;
+ }
+
May be we might want to have a findSection in Layout ?
> if (_context.isDynamic()) {
> _dynamicTable.reset(new (_alloc) DynamicTable<ELFT>(
> _context, ".dynamic", DefaultLayout<ELFT>::ORDER_DYNAMIC));
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=193662&r1=193661&r2=193662&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue Oct 29 19:02:04 2013
> @@ -26,6 +26,7 @@
> #include "llvm/Object/ELF.h"
> #include "llvm/Support/Allocator.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/Dwarf.h"
> #include "llvm/Support/ELF.h"
> #include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/FileOutputBuffer.h"
> @@ -1284,6 +1285,52 @@ private:
> std::vector<uint32_t> _chains;
> const DynamicSymbolTable<ELFT> *_symbolTable;
> };
> +
> +template <class ELFT> class EHFrameHeader : public Section<ELFT> {
> +public:
> + EHFrameHeader(const ELFLinkingContext &context, StringRef name, int32_t order)
> + : Section<ELFT>(context, name) {
_ehFrameAddr uninitialized ?
> + virtual void finalize() LLVM_OVERRIDE {
> + MergedSections<ELFT> *s = this->_context.template getTargetHandler<ELFT>()
> + .targetLayout()
> + .findOutputSection(".eh_frame");
> + _ehFrameAddr = s ? s->virtualAddr() : 0;
Could this be 0 et all ?
Thanks
Shankar Easwaran
More information about the llvm-commits
mailing list