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

    <tr>
        <th>Summary</th>
        <td>
            [BOLT] llvm-bolt using "--update-debug-sections" produces corrupted debug symbols in (dwarf64 and dwarf32) binary. 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            BOLT
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ARG-NK
      </td>
    </tr>
</table>

<pre>
    I am optimizing a ELF64/AArch64 binary compiled with coexisting dwarf32 and dwarf64 formats. 
BOLT (llvm-bolt --update-debug-sections) produces corrupted debug sections/symbols and are unreadable with consumers like readelf, gdb or llvm-dwarfdump. 

**Does BOLT support updating debug sections with dwarf64 format ?**  or Can BOLT emit header with first 4bytes of initial length field as ''0xffffffff" for dwarf64 format ? 

1. readelf -w <file.so>
![image](https://github.com/llvm/llvm-project/assets/158327801/8ea65a97-288e-48d3-98a1-42983e4c1db4)

2. llvm-dwarfdump --debug-info <file.so>
![image](https://github.com/llvm/llvm-project/assets/158327801/c46ad440-f0ec-40e2-9473-906227d2d284)
(somehow readelf interrupts a different Unit length compared to llvm-dwarfdump !?)

hexDump: 
first Unit at start of debug section: 
![image](https://github.com/llvm/llvm-project/assets/158327801/21708664-6338-4bb0-b3fc-8990a9efdf56)

second Unit starts at : 0x359eaa0 + 4 (headerLength) + 0x0ff561 (Unit size) = 0x369e005
![image](https://github.com/llvm/llvm-project/assets/158327801/359785c7-53e5-48f6-a4b4-e9cb2ac8d01f)
 

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VVFv6zYP_TXKC6FApmTZfshD2tx8-LBiA4btB0gWnWizrUCS1_b--kFO0t4W24A93AVBYoASeQ4PfWhS8qeZaMfqB1YfNmbJ5xB3-5__x3_8YWODe939H8wE4ZL95L_6-QQGvjwdtWJ43O9jf9YKrJ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