This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Expand regions for gaps due to explicit address
ClosedPublic

Authored by yodaldevoid on Aug 4 2019, 10:36 AM.

Details

Summary

If the dot gets moved by an explicit section address, an empty gap between sections could be created. The encompassing region for the section being parsed needs to be expanded to include the gap.

Diff Detail

Repository
rL LLVM

Event Timeline

yodaldevoid created this revision.Aug 4 2019, 10:36 AM
MaskRay added inline comments.Aug 4 2019, 7:32 PM
lld/test/ELF/linkerscript/section-gap-explicit-expr.test
7 ↗(On Diff #213256)

single-dash long options are discouraged in llvm-objdump. Use -h or --section-headers. I would use llvm-readelf -S.

16 ↗(On Diff #213256)

ORIGIN(REGION) is not important in this test. You can just write:

SECTIONS {
  .aaa_s 0 : { *(.aaa) } > REGION
  .bbb_s 0x14 : { *(.bbb) } > REGION
}

There is no need to copy out-of-order-section-in-region.test. How about renaming to memory-*? There are several memory region tests named memory-* now. It'd be ideal to have a single dedicated prefix for these tests.

MaskRay added inline comments.Aug 4 2019, 7:49 PM
lld/test/ELF/linkerscript/section-gap-explicit-expr.test
3 ↗(On Diff #213256)

echo ".section .aaa, 'a'; .quad 0; ..."

4 ↗(On Diff #213256)

-o %t.o

ld.lld ... %t.o -o %t

I have updated the diff and I believe I have addressed all concerns that were brought up.

MaskRay accepted this revision.Aug 5 2019, 9:09 PM
This revision is now accepted and ready to land.Aug 5 2019, 9:09 PM

I do not have commit access so if someone else could commit this patch for me I would appreciate it.

I do not have commit access so if someone else could commit this patch for me I would appreciate it.

I can commit but I'd like @ruiu to take a look first.

lld/test/ELF/linkerscript/memory-gap-explicit-expr.test
8 ↗(On Diff #213516)

Any particular reason the output section is .aaa_s while the input section is .aaa. I don't think that matters but it may make people puzzled

I can commit but I'd like @ruiu to take a look first.

Understandable.

lld/test/ELF/linkerscript/memory-gap-explicit-expr.test
8 ↗(On Diff #213516)

I made it .aaa_s when debugging so that I could differentiate printouts referring to sections as defined in the "program" and sections as defined in the linker script.

ruiu added a comment.Aug 7 2019, 3:30 AM

LGTM

I think this makes sense. Let me submit this tomorrow (I'm leaving now, and I don't want to take a risk to break buildbots.)

This revision was automatically updated to reflect the committed changes.