Debug info for comdat functions

Jakub Jelinek jakub@redhat.com
Wed Apr 18 11:53:00 GMT 2012


Hi!

Something not addressed yet in dwz and unfortunately without
linker or compiler help not 100% addressable is debug info for
comdat functions.

Consider attached testcase with comdat foo function, seems the
current linker behavior (well, tested with 2.21.53.0.1 ld.bfd)
is that for DW_TAG_subprogram with DW_AT_low_pc/DW_AT_high_pc
having section relative relocs against comdat functions
if the comdat text section has the same size in both object
files, then DW_AT_low_pc (and DW_AT_high_pc) attributes
in both CUs will point to the same range.
E.g. when compiling g++ -gdwarf-4 -o t9 t91.C t92.C, both
.text._Z3fooi sections are indentical one byte.
I think if the section content is identical, then what the
linker does is fine and perhaps dwz could just do something
with it later on (currently it doesn't consider DIEs with
DW_AT_low_pc/DW_AT_high_pc/DW_AT_ranges attributes for dup
removal).  If both .text._Z3fooi sections have different
sizes, then the linker will clear DW_AT_low_pc/DW_AT_high_pc,
which is also fine (compile e.g. t91.C with -O2 and t92.C with -O0).
I guess most debug info consumers will ignore the 0..0 range
and dwz could be tought to do something about those DW_TAG_subprogram
nodes too (what exactly?  Drop DW_AT_{low_pc,high_pc,ranges} attribute
from them, drop all DW_TAG_inlined_subroutine/DW_TAG_lexical_block
children (perhaps all children?) of them, rewrite .debug_loc section
if some portion of it was only referenced by to be removed DIEs?).

The problematic case (I'd say a linker bug) is when the .text._Z3fooi
sections have the same size, but different content (compiled with
different options, but by lack of luck happened to have the same size).
Tested by hacking up t91.s and t92.s both built with -O2 to have different,
but same sized, instructions in .text._Z3fooi.  IMHO in that case
will debug info consumers see wrong debug info and dwz can't guess what
DIE describes the actual content and what DIE describes something
that has been removed.

For the libreoffice test files I have (and libstdc++.so) I've quickly
hacked up a guess how much could be saved by handling the comdats
in dwz - the numbers are the size of DW_TAG_subprogram DIE and all its
children if the same values of both DW_AT_low_pc/DW_AT_high_pc attributes
were already seen in another DIE.  Possible .debug_loc saving isn't
accounted for, on the other side cost of DW_TAG_imported_unit,
DW_TAG_partial_unit and/or keeping around a small portion of the
DW_TAG_subprogram die for 0..0 ranges isn't in either.

liblwpftlo.so.debug 1160625
libooxlo.so.debug 939155
libswlo.so.debug 819029
libooxmllo.so.debug 789318
libsclo.so.debug 740099
libchartmodello.so.debug 636127
libsdlo.so.debug 592827
libdbulo.so.debug 458561
libsvxcorelo.so.debug 455718
libchartcontrollerlo.so.debug 418735
libfrmlo.so.debug 410486
slideshow.uno.so.debug 392586
libdbalo.so.debug 374204
libfwklo.so.debug 359078
libxolo.so.debug 327187
libsfxlo.so.debug 294460
vbaobj.uno.so.debug 282619
libtklo.so.debug 239364
libacclo.so.debug 227900
libvcllo.so.debug 209380
libdrawinglayerlo.so.debug 202697
libbf_frmlo.so.debug 192942
libscfiltlo.so.debug 188769
libbf_xolo.so.debug 184482
libbf_svxlo.so.debug 178985
libdbtoolslo.so.debug 172211
vbaswobj.uno.so.debug 169971
libbf_swlo.so.debug 169310
libsvtlo.so.debug 165993
libmswordlo.so.debug 151021
libcharttoolslo.so.debug 148725
libdoctoklo.so.debug 148573
libcomphelpgcc3.so.debug 143429
cairocanvas.uno.so.debug 142835
libbf_sclo.so.debug 140327
libcuilo.so.debug 133518
libpcrlo.so.debug 132128
i18npool.uno.so.debug 125995
vclcanvas.uno.so.debug 117225
libdeployment.so.debug 109223
libchartviewlo.so.debug 101869
libsvxlo.so.debug 96798
librptuilo.so.debug 95625
postgresql-sdbc-impl.uno.so.debug 95311
libswuilo.so.debug 94986
msforms.uno.so.debug 88318
libutllo.so.debug 72778
libbf_svtlo.so.debug 67642
libunoxmllo.so.debug 65290
libfilterconfiglo.so.debug 64802
libsblo.so.debug 63344
librptlo.so.debug 60664
libvbahelperlo.so.debug 60292
libbf_schlo.so.debug 58526
configmgr.uno.so.debug 58439
libeditenglo.so.debug 57242
libfilelo.so.debug 56444
libfwllo.so.debug 53012
libpackage2.so.debug 50186
libxcrlo.so.debug 49733
libcppcanvaslo.so.debug 47957
libbasctllo.so.debug 40421
libbf_sdlo.so.debug 38870
libsvllo.so.debug 37970
libxsec_fw.so.debug 34438
libjdbclo.so.debug 33137
libdbaselo.so.debug 32789
libxmlsecurity.so.debug 32416
libhsqldb.so.debug 32403
libsmlo.so.debug 32339
libuuilo.so.debug 30973
liblnglo.so.debug 29532
libfwelo.so.debug 28311
libodbcbaselo.so.debug 27829
librptxmllo.so.debug 27530
libwpftlo.so.debug 26609
libscuilo.so.debug 26554
libucpchelp1.so.debug 25999
libdeploymentgui.so.debug 25982
libmysqllo.so.debug 25576
libfwilo.so.debug 25144
libembobj.so.debug 23555
libxstor.so.debug 23167
libsofficeapp.so.debug 23124
libmsfilterlo.so.debug 22551
libdbaxmllo.so.debug 22032
libucpfile1.so.debug 21467
libxsec_xmlsec.so.debug 19768
libevoablo.so.debug 19409
libspalo.so.debug 18660
libflatlo.so.debug 18345
libucbhelper4gcc3.so.debug 18066
libsdfiltlo.so.debug 17906
libcalclo.so.debug 17773
libucpdav1.so.debug 17769
libmsworkslo.so.debug 16706
libsduilo.so.debug 15592
libxoflo.so.debug 13298
librtftoklo.so.debug 12403
migrationoo2.uno.so.debug 12237
libpyuno.so.debug 11670
libxsltdlglo.so.debug 10628
libemboleobj.so.debug 10156
fps_office.uno.so.debug 10020
libstdc++.so 9718
libucb1.so.debug 9121
libcanvastoolslo.so.debug 9059
libwpgimportlo.so.debug 9035
libvisioimportlo.so.debug 9035
libpllo.so.debug 8327
libscriptframe.so.debug 8290
libbf_sblo.so.debug 7769
libbiblo.so.debug 7731
libvclplug_gtklo.so.debug 7691
libloglo.so.debug 7591
libucpftp1.so.debug 7388
libfwmlo.so.debug 7056
ucptdoc1.uno.so.debug 7025
libsvgfilterlo.so.debug 6935
libcached1.so.debug 6869
basprov.uno.so.debug 6577
libvclplug_genlo.so.debug 6439
libsotlo.so.debug 6156
libhelplinkerlo.so.debug 6143
libdbplo.so.debug 5872
libunordflo.so.debug 5840
libucphier1.so.debug 5810
libsdbtlo.so.debug 4974
libreslo.so.debug 4886
libbf_smlo.so.debug 4785
libwriterfilterlo.so.debug 4776
libvclplug_svplo.so.debug 4688
libdeploymentmisclo.so.debug 4503
libpdffilterlo.so.debug 4500
libunopkgapp.so.debug 4269
libbf_solo.so.debug 4264
libdbmmlo.so.debug 4246
fsstorage.uno.so.debug 4107
libhwplo.so.debug 3978
libbasegfxlo.so.debug 3864
libctllo.so.debug 3723
libabplo.so.debug 3607
libresourcemodello.so.debug 3123
libflashlo.so.debug 2889
ucpgio1.uno.so.debug 2612
expwrap.uno.so.debug 2504
dlgprov.uno.so.debug 2481
cmdmail.uno.so.debug 2388
liblnthlo.so.debug 2236
libicglo.so.debug 2145
libucppkg1.so.debug 2075
libdbpool2.so.debug 2048
libforuilo.so.debug 1858
ucpcmis1.uno.so.debug 1838
libspelllo.so.debug 1838
libhyphenlo.so.debug 1838
libxsltfilterlo.so.debug 1837
nsplugin.debug 1737
libtllo.so.debug 1682
libsrtrs1.so.debug 1599
libavmediagst.so.debug 1462
libavmedialo.so.debug 1409
hatchwindowfactory.uno.so.debug 1386
libtvhlp1.so.debug 1375
libanimcorelo.so.debug 1345
libanalysislo.so.debug 1278
libmozbootstrap.so.debug 1258
libbasebmplo.so.debug 1229
passwordcontainer.uno.so.debug 1151
libsaxlo.so.debug 1094
fastsax.uno.so.debug 1061
libtextconversiondlgslo.so.debug 941
ucpext.uno.so.debug 690
libplacewarelo.so.debug 654
libadabasuilo.so.debug 647
libguesslanglo.so.debug 617
libmcnttype.so.debug 516
libt602filterlo.so.debug 512
libscnlo.so.debug 429
libforlo.so.debug 427
libxmlfalo.so.debug 333
kde4be1.uno.so.debug 204
libbf_wrapperlo.so.debug 186
libspllo.so.debug 184
gconfbe1.uno.so.debug 130
libvclplug_kde4lo.so.debug 127
spadmin.bin.debug 124
libxmxlo.so.debug 124
fps_kde4.uno.so.debug 124
syssh.uno.so.debug 116
libxmlfdlo.so.debug 62
libswdlo.so.debug 62
libsmdlo.so.debug 62
libsddlo.so.debug 62
libsdbc2.so.debug 62
libscdlo.so.debug 62
libbf_migratefilterlo.so.debug 62


	Jakub
-------------- next part --------------
inline void
bar (int d)
{
  int e = d + 5;
  asm ("");
}

inline void
foo (int a)
{
  int b = a + 1;
  asm ("");
  {
    int c = 2 * a + b + 26;
    asm ("");
  }
}

struct S
{
  void baz (int f) { int g = f + 4; asm (""); }
  int s;
};
-------------- next part --------------
#include "t9.h"

void *x = (void *) foo;

void
fn1 ()
{
  S s;
  foo (4);
  s.baz (12);
}

int
main ()
{
  return 0;
}
-------------- next part --------------
#include "t9.h"

void *y = (void *) foo;

void
fn2 ()
{
  S s;
  foo (4);
  s.baz (12);
}


More information about the Binutils mailing list