[llvm-bugs] [Bug 35553] New: Dummy sections should be NOBITS

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 6 12:56:58 PST 2017


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

            Bug ID: 35553
           Summary: Dummy sections should be NOBITS
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: jakehehrlich at google.com
                CC: llvm-bugs at lists.llvm.org

When given a linker script that creates a section with no input sections and no
byte commands the linker should make the output section have type NOBITS to
reduce the size of the final executable (assuming that the NOBITS sections
occur at the end of the segment). Right now LLD produces PROGBITS sections in
this case.

I thought it would be simple to simply make the default output section type be
NOBITS and then change the type to PROGBITS during finalization if a byte
command was seen but this leads to more complicated issues in
test/ELF/linkerscript/extend-pt-load.s and my naive attempt to fix that caused
other problems in test/ELF/linkerscript/orphan-discard.s. Looking in to this
the issue seems more complicated than I gave it credit for.

Steps to reproduce:

test.ll```
SECTIONS {
  .foo : {
    . += 0x1000;
  }
}
```

test.s```
.global _start
.type _start, STT_FUNC

_start:
  ret
```

Then run the following
```
lld --script=test.ll test.o -o test
llvm-readobj -sections test
```

And the .foo section will look like this:
```
  Section {
    Index: 1
    Name: .foo (1)
    Type: SHT_PROGBITS (0x1)
    Flags [ (0x2)
      SHF_ALLOC (0x2)
    ]
    Address: 0x0
    Offset: 0x1000
    Size: 4096
    Link: 0
    Info: 0
    AddressAlignment: 1
    EntrySize: 0
  }

```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171206/1c749a32/attachment.html>


More information about the llvm-bugs mailing list