What to do about alignment of ELF objects
Rafael EspĂndola
rafael.espindola at gmail.com
Wed Apr 22 12:06:00 PDT 2015
Currently the lower level APIs keep track of the alignment of elf
objects in memory.
At some point along the layers we switch to just using 2 byte
alignment because of archives.
One option is to just use 2 everywhere.
Another is to copy the data to make it aligned. These patches do just that.
I tested them by linking an X86_64 clang in an ppc64le machine. Having
aligned access seems to help on ppc64le:
trunk:
2.165775601 seconds time elapsed
( +- 2.67% )
patch:
1.979675092 seconds time elapsed
( +- 2.96% )
The main missing issue is the memory leak. The reason we can't have
Archive just own the buffer for the unaligned members is that in lld
we have
----------------------------------------
FileVector loadFile(LinkingContext &ctx, StringRef path, bool wholeArchive) {
ErrorOr<std::unique_ptr<MemoryBuffer>> mb
= MemoryBuffer::getFileOrSTDIN(path);
if (std::error_code ec = mb.getError())
return makeErrorFile(path, ec);
std::vector<std::unique_ptr<File>> files;
if (std::error_code ec = ctx.registry().loadFile(std::move(mb.get()), files))
return makeErrorFile(path, ec);
if (wholeArchive)
return parseMemberFiles(files);
return files;
}
--------------------------------------
So if --whole-archive is used, the Archive itself is freed and we then
try to use the members.
Should the registry have a place for putting Archives?
Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.patch
Type: text/x-patch
Size: 25990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150422/8aa070a0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lld.patch
Type: text/x-patch
Size: 3024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150422/8aa070a0/attachment-0001.bin>
More information about the llvm-commits
mailing list