<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>I found this blog entry that explains why:<br><span><a target="_blank" href="http://blogs.sun.com/dbx/entry/dwarf_and_relocations">http://blogs.sun.com/dbx/entry/dwarf_and_relocations</a></span><br><br>I may write a patch that changes the comment to reflect this.<br><br>- Jan<br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Jan Sjodin <jan_sjodin@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> Rafael Avila de Espindola <rafael.espindola@gmail.com>; llvm-commits@cs.uiuc.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Tue, March 22, 2011 4:45:35
 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br></font><br>
<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div><br>I had accidentally put this comment for a different patch:<br><br>> I was continuing to try and see what the problem actually was. The 
difference between the machines was that th debuginfo for glibc was 
included on the test machine but not my own. I did a small test and 
linked in a dummy <br>> file before the test file and was able to reproduce 
the issue. This means that there is a bug somewhere else or that the 
"optimization" is really something required and the comment should be 
updated<br>><br>>- Jan</div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br>In any case I think I am stuck and need some help.  I found the two offsets in the generated .s files that causes the bug:<br><br>.Lset32 = .Labbrev_begin-.Lsection_abbrev # Offset Into Abbrev. Section<br>    .long    .Lset32<br><br>and<br><br>.Lset34 = .Linfo_begin1-.Lsection_info  # Offset of Compilation Unit Info<br>    .long    .Lset34<br><br>This will not work unless the resulting .o file appears first in the list of files to be linked, or if all object files before do not have any debug information.<br><br>Without the patch these look like:<br>.long    .Labbrev_begin          # Offset Into Abbrev. Section<br>and<br> .long   
 .Linfo_begin1           # Offset of Compilation Unit Info<br><br>In lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp we have this code:<br>// If the section in question will end up with an address of 0 anyway, we can<br> // just emit an absolute reference to save a relocation.<br>if (Section.isBaseAddressKnownZero()) {<br>  OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/);<br>   return;<br> }<br>  <br>The comment for the optimization cannot be true since without this, the generated code is wrong. I wanted to know why the above values cannot be differences, but have to be direct references. Is it a different kind of offset? If so, should LLVM distinguish between different kinds of offsets? I would be happy if someone with more knowledge could explain.<br><br>- Jan<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2"
 face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Jan Sjodin <jan_sjodin@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> Rafael Avila de Espindola <rafael.espindola@gmail.com>; llvm-commits@cs.uiuc.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, March 17, 2011 5:59:13 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br></font><br>
<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div>Test machine: GNU ld (GNU Binutils for Debian) 2.18.0.20080103<br>My machine: GNU ld (GNU Binutils for Ubuntu) 2.20.51-system.20100908<br><br>I actually did a few different things to see if I could possibly reproduce the problem on my machine.<br>1. I downloaded the closest versions of gdb, gcc and binutils that i could find:<br>   Test machine: gcc (Debian 4.3.2-1.1) 4.3.2,  GNU gdb 6.8-debian and binutils (see above)<br>   Downloaded and compiled: gcc 4.3.2, gdb 6.8 and  binutils 2.18<br>2. Compiled llvm, llvm-gcc with these and was not able to reproduce the problem.<br>3. Copied the ld binary and <a rel="nofollow" target="_blank" href="http://libbfd-2.18.0.20080103.so">libbfd-2.18.0.20080103.so</a> from the test machine to my own machine to see if I could use that linker to reproduce the error, and still was not able to reproduce the
 problem.<br><br>There is something weird going on with that specific machine and I have no clue what it is. I know that ld is involved somehow. Perhaps it is some other supporting library that is at fault.<br><br>- Jan<br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: Courier New,monaco,monospace,sans-serif; font-size: 10pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Rafael Avila de Espindola <rafael.espindola@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> llvm-commits@cs.uiuc.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, March 17, 2011 4:41:03 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br></font><br>
On 11-03-17 03:57 PM, Jan Sjodin wrote:<br>> I have been investigating this failure for the past couple of days.<br>> There is something wrong with the linker on the test machine. If i take<br>> the generated asm file (.s) and assemble and link on my own machine it<br>> works fine. If i assemble on the test machine and link on my machine it<br>> works fine, but if I link on the test machine the ELF format becomes<br>> corrupted somehow. This shows up e.g. with readelf -a, where the object<br>> file is okay, but the binary does not list the symbol table (it is there<br>> and can be listed with readelf -s) The patch should be good otherwise,<br>> the object file is smaller with the patch than without.<br><br>What are the liker versions on both cases?<br><br>> - Jan<br><br>Cheers,<br>Rafael<br>_______________________________________________<br>llvm-commits mailing list<br><a rel="nofollow"
 ymailto="mailto:llvm-commits@cs.uiuc.edu" target="_blank" href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><span><span><span><a target="_blank" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></span></span></span><br></div></div>
</div></div></div>
</div></div></div>
</div></body></html>