Page MenuHomePhabricator

[ELF] - Set the sh_entsize for mergable sections
ClosedPublic

Authored by grimar on Mar 17 2016, 10:31 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 50954.Mar 17 2016, 10:31 AM
grimar retitled this revision from to [ELF] - Set the sh_entsize for mergable sections.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
grimar added inline comments.Mar 17 2016, 10:38 AM
ELF/OutputSections.cpp
1223 ↗(On Diff #50954)

I think there is no rule what EntSize to take. Gold uses the first size he saw here:

.section	.rodata.1,"aMS",@progbits,2
.asciz	"a"

.section        .rodata.1,"aMS",@progbits,1
.asciz	"b"
...
            
  EntSize == 2:
  [ 2] .rodata.1         PROGBITS         0000000000000000  00000040  0000000000000004  0000000000000002
.section	.rodata.1,"aMS",@progbits,1
.asciz	"a"

.section        .rodata.1,"aMS",@progbits,2
.asciz	"b"

...

  EntSize == 1:               
  [ 2] .rodata.1         PROGBITS         0000000000000000  00000040  0000000000000004  0000000000000001

So I think there is no need in any conditions and we can just assign here.

emaste added a subscriber: emaste.Mar 17 2016, 11:53 AM

Perhaps sections with different sh_entsize should not be mergable?
But I think this is fine either way.

rafael accepted this revision.Mar 17 2016, 2:52 PM
rafael edited edge metadata.

LGTM.

Thanks!

This revision is now accepted and ready to land.Mar 17 2016, 2:52 PM
This revision was automatically updated to reflect the committed changes.
ruiu added inline comments.Mar 18 2016, 2:47 AM
lld/trunk/ELF/OutputSections.cpp
1223

Setting a header value from addSection would be a bit confusing because it runs multiple times. I'd do that in finalize().

grimar added inline comments.Mar 18 2016, 2:56 AM
lld/trunk/ELF/OutputSections.cpp
1223

Am I missing something, but we dont have access to sh_entsize from finalize. I mean we dont store a list of added sections to take it there.

ruiu edited edge metadata.Mar 18 2016, 3:02 AM
ruiu added a subscriber: ruiu.

Ah, right. I thought that we have a list of input sections, but we actually
don't have that.