<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Dummy sections should be NOBITS"
   href="https://bugs.llvm.org/show_bug.cgi?id=35553">35553</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Dummy sections should be NOBITS
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jakehehrlich@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
  }

```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>