<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/107064>107064</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLD generates different symbol types and SIZEOF return fixed sizes seemingly violating deferred evaluation.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lld
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Lusacan
      </td>
    </tr>
</table>

<pre>
    Given the following ASM:

**input.s:**
```
.section ".isec", "ax", @progbits
    .global _start
    .align 2
    .type _start, @function
_start:
    .quad osec_size_outside_front
    .quad osec_size_inside_front
    .quad osec_size_inside_back
    .quad osec_size_outside_back
    .size _start, .-_start
```

and the following linker script:
**linker.ld:**
```
SECTIONS {
 PROVIDE(osec_size_outside_front = SIZEOF(.osec));
    .osec 0 : {nm result
        PROVIDE(osec_size_inside_front = SIZEOF(.osec));
 *(.isec*)
        PROVIDE(osec_size_inside_back = SIZEOF(.osec));
 }
    PROVIDE(osec_size_outside_back = SIZEOF(.osec));
}
```

Using the GNU and the latest LLVM we get different results for the symbolic link size and types for "osec_size_inside_front" calling nm on the compiled result.elf.

`GCC 11.4.0: `
```
$ as input.s -o input.o
$ ld -o result.elf -T linker.ld input.o
$ nm result.elf
0000000000000020 T osec_size_inside_back
0000000000000020 T osec_size_inside_front
0000000000000020 A osec_size_outside_back
0000000000000020 A osec_size_outside_front
0000000000000000 T _start
```
**LLVM 14.0.0:**
```
$ clang -c input.s -o input.o
$ ld.lld -o result.elf -T linker.ld input.o
$ nm result.elf
0000000000000020 A osec_size_inside_back
0000000000000000 A osec_size_inside_front
0000000000000020 A osec_size_outside_back
0000000000000020 A osec_size_outside_front
0000000000000000 T _start
```

It is true that the use of SIZEOF is not appropriate from the aspect of the unfinished section and ordering, but
according to the [](https://lld.llvm.org/ELF/linker_script.html) every difference should be reported.

</pre>
<img width="1px" height="1px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