lkml.org 
[lkml]   [1999]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Dependencies for init functions
Alan Cox wrote:
>
> > Would you support such a scheme? If yes, I'm willing to do
> > the implementation (catdep already exists :-)).
>
> It sounds a good solution to me

Hi Alan,
I'm a little bit excited because I got a first rough cut of
the code working. It consists of basically 3 programs:

fiximage: this one actually manipulates the ELF image file

symaddr : resolves a list of symbol name sto their address

catdep : converts a dependency description of the form
"a b: c d" (symbol a and b depend on c and d)
into input suitable for tsort.

Additional, there is a small test program, that places a number
of functions into the .ctors section.

To test it:
1) compile all 4 programs (fiximage needs libelf).
2) create a symbol file for the demo image (i.e. nm ./demo | grep foo. > demo.sym)
3) specify a dpendency for foo1..foo7, for instance
foo1: foo3 foo4
foo4: foo2
foo2: foo5
4) to test catdep do:
pommnitz ~/fiximage>./catdep dependencies | tsort
foo1
foo4
foo3
foo2
foo5
5) to test symaddr, add another stage to the pipe:
pommnitz ~/fiximage>./catdep inp | tsort | ./symaddr -f demo.sym
0x80483d0
0x8048460
0x8048430
0x8048400
0x8048490
6) to test fiximage, you have to do a before/after comparison:
pommnitz ~/fiximage>objdump --section=.ctors --full-contents demo

demo: file format elf32-i386

Contents of section .ctors:
80495b8 ffffffff d0830408 00840408 30840408 ............0...
80495c8 60840408 90840408 c0840408 f0840408 `...............
80495d8 00000000 ....
pommnitz ~/fiximage>./catdep dependencies | tsort | ./symaddr -f demo.sym | ./fiximage -f demo -s .ctors
pommnitz ~/fiximage>objdump --section=.ctors --full-contents demo

demo: file format elf32-i386

Contents of section .ctors:
80495b8 d0830408 60840408 30840408 00840408 ....`...0.......
80495c8 90840408 ffffffff c0840408 f0840408 ................
80495d8 00000000 ....

The resulting binary still does run. However, it seems that the
.ctors section for user binaries is not just a table listing all
the constructors but uses 0xffffffff and 0x00000000 to mark the
start and the end of the table. fiximage does works around this
with a disgusting hack. Oh, and it seems that the C runtime
walks the .ctors table in the wrong direction...




--
Regards
Joerg
GMD-IPSI, Dolivostr. 15, Zimmer 120, D-64293 Darmstadt
+49-6151-869-786 (Phone), -818 (FAX)[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.035 / U:0.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site