Page MenuHomePhabricator

[lld] Fix output section offset and contents when linker script uses memory region and data commands
ClosedPublic

Authored by owenpshaw on Dec 20 2017, 11:24 AM.

Details

Summary

Advance the memory region offset when handling a linker script data command such as BYTE or LONG. Failure to advance the offset results in corrupted output with overlapping sections.

Update tests to check for this combination of both a) memory regions and b) data commands.

Fixes https://bugs.llvm.org/show_bug.cgi?id=35565

Diff Detail

Event Timeline

owenpshaw created this revision.Dec 20 2017, 11:24 AM
grimar added a subscriber: grimar.Dec 21 2017, 1:30 AM

You need to add reviewers when posting the patches. It is at least Rui as code owner of LLD.
Logic of patch looks correct for me. I'll add him.

ELF/LinkerScript.cpp
696

You do not need bracers around single line.

test/ELF/linkerscript/data-commands.s
47
MEMORY {
51
SECTIONS {
grimar added a reviewer: ruiu.Dec 21 2017, 1:30 AM

"Group Reviewers lld" (https://reviews.llvm.org/project/members/2/)
you used is something new for me honestly, but looking at members I suspect it
is just an old group used for old LLD (different elf linker existed before this one, new LLD).

owenpshaw removed a reviewer: lld.

Thanks for the help!

Updated the patch with suggested changes to braces.

I have no other comments, this looks good to me. You need approval from reviewers to commit.

owenpshaw accepted this revision.Dec 27 2017, 8:42 AM
This revision is now accepted and ready to land.Dec 27 2017, 8:42 AM
owenpshaw closed this revision.Dec 27 2017, 8:43 AM

Closing. As already noted in mailing list, Rafael committed this change as r321418.