<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 update section start address"
   href="https://bugs.llvm.org/show_bug.cgi?id=37608">37608</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLD does not update section start address
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>eblot.ml@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20346" name="attach_20346" title="Sample code to reproduce the issue">attachment 20346</a> <a href="attachment.cgi?id=20346&action=edit" title="Sample code to reproduce the issue">[details]</a></span>
Sample code to reproduce the issue

Hi,

Using LLD 6.0.0 (host: macOS, target: armv7em bare metal), it seems LLD fails
to properly compute the start address of some of the successive sections, for
example in the following subset:

    .pstack :
    {
        . = ALIGN(8);
        __process_stack_base__ = .;
        . += __process_stack_size__;
        . = ALIGN(8);
        __process_stack_end__ = .;
    } > ram0

    .mstack :
    {
        . = ALIGN(8);
        __main_stack_base__ = .;
        . += __main_stack_size__;
        . = ALIGN(8);
        __main_stack_end__ = .;
    } > ram0


I expect that __main_stack_base__ is given an address equal of greater than
__process_stack_end__.

However:

Stack map with LLVM/LLD
20000000 B __main_stack_base__
20000000 B __process_stack_base__

While:

Stack map with GNU/LD
20000400 B __main_stack_base__
20000000 B __process_stack_base__

The proper address can be obtained by forcing the start address this way:

    .mstack :
    {
        . = __process_stack_end__;
        . = ALIGN(8);
        __main_stack_base__ = .;
        . += __main_stack_size__;
        . = ALIGN(8);
        __main_stack_end__ = .;
    } > ram0

but it seems awkward.

I'm attaching a tiny tarball file w/ a build.sh script that reproduces the
issue with a very trivial application.</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>