xref: /aosp_15_r20/external/elfutils/NOTES (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard WorkerFundamental design decision:
2*7304104dSAndroid Build Coastguard Worker
3*7304104dSAndroid Build Coastguard Worker- the sizes of external and internal types are assumed to be the same.
4*7304104dSAndroid Build Coastguard Worker  This leaves byte ordering aside.  While assuming this the code can be
5*7304104dSAndroid Build Coastguard Worker  greatly simplified and speed increases.  Since no change violating this
6*7304104dSAndroid Build Coastguard Worker  assumption is in sight this is believed to be a worthwhile optimization.
7*7304104dSAndroid Build Coastguard Worker
8*7304104dSAndroid Build Coastguard Worker- the ABI of the backend modules is not guaranteed.  Really, no guarantee
9*7304104dSAndroid Build Coastguard Worker  whatsoever.  We are enforcing this in the code.  The modules and their
10*7304104dSAndroid Build Coastguard Worker  users must match.  No third-party EBL module are supported or allowed.
11*7304104dSAndroid Build Coastguard Worker  The only reason there are separate modules is to not have the code for
12*7304104dSAndroid Build Coastguard Worker  all architectures in all the binaries.
13*7304104dSAndroid Build Coastguard Worker
14*7304104dSAndroid Build Coastguard Worker- although the public libraries (libasm, libdw) have a stable API and are
15*7304104dSAndroid Build Coastguard Worker  backwards ABI compatible they, and the elfutils tools, do depend on each
16*7304104dSAndroid Build Coastguard Worker  others internals, and on internals of libelf to provide their interfaces.
17*7304104dSAndroid Build Coastguard Worker  So they should always be upgraded in lockstep when packaging the tools
18*7304104dSAndroid Build Coastguard Worker  and libraries separately. For one example of how to do that, see the
19*7304104dSAndroid Build Coastguard Worker  config/elfutils.spec.
20*7304104dSAndroid Build Coastguard Worker
21*7304104dSAndroid Build Coastguard WorkerSome notes:
22*7304104dSAndroid Build Coastguard Worker
23*7304104dSAndroid Build Coastguard Worker- old GNU ld's behavior wrt DSOs seems to be severely broken.
24*7304104dSAndroid Build Coastguard Worker
25*7304104dSAndroid Build Coastguard Worker     y.o reference foo()
26*7304104dSAndroid Build Coastguard Worker     y1.o defines foo(), references bar()
27*7304104dSAndroid Build Coastguard Worker     y2.o defines bar()
28*7304104dSAndroid Build Coastguard Worker     libbar.so defines bar()
29*7304104dSAndroid Build Coastguard Worker
30*7304104dSAndroid Build Coastguard Worker  Running
31*7304104dSAndroid Build Coastguard Worker
32*7304104dSAndroid Build Coastguard Worker     gcc -o y y.o -lbar y1.o y2.o
33*7304104dSAndroid Build Coastguard Worker
34*7304104dSAndroid Build Coastguard Worker  uses the bar() definition from libbar.so and does not mention the definition
35*7304104dSAndroid Build Coastguard Worker  in y2.o at all (no duplicate symbol message).  Correct is to use the
36*7304104dSAndroid Build Coastguard Worker  definition in y2.o.
37*7304104dSAndroid Build Coastguard Worker
38*7304104dSAndroid Build Coastguard Worker
39*7304104dSAndroid Build Coastguard Worker     y.o reference foo()
40*7304104dSAndroid Build Coastguard Worker     y1.o defines foo(), references bar()
41*7304104dSAndroid Build Coastguard Worker     y2.o in liby2.a defines bar()
42*7304104dSAndroid Build Coastguard Worker     libbar.so defines bar()
43*7304104dSAndroid Build Coastguard Worker
44*7304104dSAndroid Build Coastguard Worker  Running
45*7304104dSAndroid Build Coastguard Worker
46*7304104dSAndroid Build Coastguard Worker     gcc -o y y.o -lbar y1.o -ly3
47*7304104dSAndroid Build Coastguard Worker
48*7304104dSAndroid Build Coastguard Worker  has to use the definition in -lbar and not pull the definition from liby3.a.
49*7304104dSAndroid Build Coastguard Worker
50*7304104dSAndroid Build Coastguard Worker
51*7304104dSAndroid Build Coastguard Worker- the old linker follows DT_NEEDED entries and adds the objects referenced
52*7304104dSAndroid Build Coastguard Worker  this way which define a symbol which is needed as a DT_NEEDED to the
53*7304104dSAndroid Build Coastguard Worker  generated binary.  This is wrong since the DT_NEEDED changes the search
54*7304104dSAndroid Build Coastguard Worker  path in the object (which is breadth first).
55*7304104dSAndroid Build Coastguard Worker
56*7304104dSAndroid Build Coastguard Worker
57*7304104dSAndroid Build Coastguard Worker- the old linker supported extern "C++", extern "java" in version scripts.
58*7304104dSAndroid Build Coastguard Worker  I believe this implementation is severely broken and needs a redesign
59*7304104dSAndroid Build Coastguard Worker  (how do wildcards work with these languages*?).  Therefore it is left
60*7304104dSAndroid Build Coastguard Worker  out for now.
61*7304104dSAndroid Build Coastguard Worker
62*7304104dSAndroid Build Coastguard Worker
63*7304104dSAndroid Build Coastguard Worker- what should happen if two sections in different files with the same
64*7304104dSAndroid Build Coastguard Worker  name have different types and/or the flags are different
65*7304104dSAndroid Build Coastguard Worker
66*7304104dSAndroid Build Coastguard Worker
67*7304104dSAndroid Build Coastguard Worker- section names in input files are mostly irrelevant.  Exceptions:
68*7304104dSAndroid Build Coastguard Worker
69*7304104dSAndroid Build Coastguard Worker  .comment/SHT_PROGBITS		in strip, ld
70*7304104dSAndroid Build Coastguard Worker
71*7304104dSAndroid Build Coastguard Worker  .debug		\
72*7304104dSAndroid Build Coastguard Worker  .line			|
73*7304104dSAndroid Build Coastguard Worker  .debug_srcinfo	|
74*7304104dSAndroid Build Coastguard Worker  .debug_sfnames	|
75*7304104dSAndroid Build Coastguard Worker  .debug_aranges	|
76*7304104dSAndroid Build Coastguard Worker  .debug_pubnames	|
77*7304104dSAndroid Build Coastguard Worker  .debug_info		|
78*7304104dSAndroid Build Coastguard Worker  .debug_abbrev		|
79*7304104dSAndroid Build Coastguard Worker  .debug_line		|
80*7304104dSAndroid Build Coastguard Worker  .debug_abbrev		 >	DWARF sections in ld
81*7304104dSAndroid Build Coastguard Worker  .debug_line		|
82*7304104dSAndroid Build Coastguard Worker  .debug_frame		|
83*7304104dSAndroid Build Coastguard Worker  .debug_str		|
84*7304104dSAndroid Build Coastguard Worker  .debug_loc		|
85*7304104dSAndroid Build Coastguard Worker  .debug_macinfo	|
86*7304104dSAndroid Build Coastguard Worker  .debug_weaknames	|
87*7304104dSAndroid Build Coastguard Worker  .debug_funcnames	|
88*7304104dSAndroid Build Coastguard Worker  .debug_typenames	|
89*7304104dSAndroid Build Coastguard Worker  .debug_varnames	/
90*7304104dSAndroid Build Coastguard Worker
91*7304104dSAndroid Build Coastguard Worker  Sections created in output files follow the naming of special section
92*7304104dSAndroid Build Coastguard Worker  from the gABI.
93*7304104dSAndroid Build Coastguard Worker
94*7304104dSAndroid Build Coastguard Worker  In no place is a section solely identified by its name.  Internal
95*7304104dSAndroid Build Coastguard Worker  references always use the section index.
96