[PATCH] D27415: [ELF] - Replace MergeOutputSection with synthetic input section MergeSection.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 26 09:35:16 PST 2017


grimar added a comment.

I found next script in linux kernel:

  .rodata : {
   *(.rodata)
   *(.rodata.*)
   . = ALIGN(16);
   video_cards = .;
   *(.videocards)
   video_cards_end = .;
  }

We generate video_cards == video_cards_end here, what is wrong and happens because we generate multiple .rodata*.
That what this patch had to fix, seems it is very good now justification about that we need this logic.
And I worked on a new patch basing on this one today (to have a cleaner version and to refresh it in mind).

I had a problem though:
Latest diff of this patch creates all mergeable sections early:

  template <class ELFT> void Writer<ELFT>::run() {
    // Create linker-synthesized sections such as .got or .plt.
    // Such sections are of type input section.
    createSyntheticSections();
    combineMergableSections(Symtab<ELFT>::X->Sections);

So on latter steps both linkerscripted case and regular case had mergeable synthetic sections instead of regular mergable input sections.
Diff 2 of that patch did that in a different way, it did the same much later, what was more flexible.

It seems that approach of latest diff will not work. It was simple, but it is too simple to work enough good I think now.
Problem is merge-sections.s for example, which has:

  .section        .foo.1a,"aMS", at progbits,1
  .asciz "foo"
  
  .section        .foo.1b,"aMS", at progbits,1
  .asciz "foo"

and script:

  # RUN:   .foo : { begin = .; *(.foo.*) end = .;}



  Latest diff creates syntetic sections .foo.1s and .foo.1b. Then script basing on rules combines them into single .foo later.

Problem is that first and second section contain exactly one regular mergeable input section section per each.
So they keep "foo" strings separatelly. What gives us 8 bytes .foo instead of 4.
Issue is that until we parse linkerscripts we unable to create syntetic section .foo with proper name early, because we do not know
that for ".foo.1a" we should create synthetic section ".foo".

  And then when we already have 2 synthetic mergeable sections .foo.1a and .foo.1b created suring script run, all we can do is place them to output,

but we can not merge them together on that step.

Diff2 on opposite created synthetic mergeable sections on linkerscript side later. What was a bit more complicated, but solved
that problem. So it took a list of regular sections, grouped mergeable together and created synthetic inputs for them. Which were added to output finally.
I think we want to have this optimization, does not ?

So I think we should return to Diff 2 approach. I am going to use it as a base, rework and upload fresh patch probably.

What do you think, Rui ?


https://reviews.llvm.org/D27415





More information about the llvm-commits mailing list