<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 - LLD does not create segments for output sections coming after .ARM.attributes in linkerscript"
   href="https://bugs.llvm.org/show_bug.cgi?id=37607">37607</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD does not create segments for output sections coming after .ARM.attributes in linkerscript
          </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>Windows NT
          </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>konstantin.schwarz@hightec-rt.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLD does not create segments for output sections coming after .ARM.attributes
section patterns in linkerscripts.

Consider the following assembler file and linker script:

// test.s
.global _start
_start:
nop


// linker.script
ENTRY(_start)

SECTIONS {

        .ARM.attributes : { *(.ARM.attributes) }

        .text : {
                *(.text*)
        }
}

llvm-readelf gives the following output:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf
Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0 
0
  [ 1] .ARM.attributes   ARM_ATTRIBUTES  00000000 000094 000030 00      0   0 
1
  [ 2] .comment          PROGBITS        00000000 0000c4 000064 01  MS  0   0 
1
  [ 3] .symtab           SYMTAB          00000000 000128 000030 10      5   2 
4
  [ 4] .shstrtab         STRTAB          00000000 000158 00003a 00      0   0 
1
  [ 5] .strtab           STRTAB          00000000 000192 00000d 00      0   0 
1
  [ 6] .text             PROGBITS        00000010 0001a0 000004 00  AX  0   0 
4
[...]

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0

 Section to Segment mapping:
  Segment Sections...
   00     

[...]

Reordering the output section description into

// linker2.script
ENTRY(_start)

SECTIONS {

        .text : {
                *(.text*)
        }
        .ARM.attributes : { *(.ARM.attributes) }
}

gives the expected result:

[...]
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x00000000 0x00000000 0x00004 0x00004 R E 0x1000
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0

 Section to Segment mapping:
  Segment Sections...
   00     .text 
   01   
[...]

arm-none-eabi-ld.bfd produces the expected output with both linkerscripts.</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>