[okl4-developer] Elfweaver Failure (was Re: OKL4 3.0: What about hardware drivers?)
Robert Wetzel
robert.wetzel at opensynergy.com
Fri Nov 14 19:56:27 EST 2008
Malcolm Purvis wrote:
>>>>>> "Robert" == Robert Wetzel <robert.wetzel at opensynergy.com> writes:
>
> Robert> After messing around with the source tarball and failing to get
> Robert> a proper 2.1-style build done thanks to a failing elfweaver
> Robert> (exits with EINVAL in a seek() operation during a modify &
> Robert> physical+_entry, looked like the segment-in-section offset
> Robert> calculation went bonkers)
>
> That's very strange behaviour for elfweaver. Would it be possible for
> you to post more details so that we can hunt down the bug?
>
> In particular, the output of 'readelf -e' on all of your input files,
> and the results of:
>
> $ elfweaver --traceback merge -o <image.elf> <weaver.xml>
>
> would be very useful
Sure. The error happens in the modify step, though, so I took the freedom to apply the traceback
on that step instead:
$ tools/pyelf/elfweaver.py --traceback modify -obuild/images/image.boot build/images/image.elf
--physical_entry --physical
/home/spex/src/okl4_3.0/tools/pyelf/elf/structures.py:350: DeprecationWarning: struct integer
overflow masking is deprecated
self.e_shstrndx)
/home/spex/src/okl4_3.0/tools/pyelf/elf/structures.py:592: DeprecationWarning: struct integer
overflow masking is deprecated
packed = pack(self.endianess + self.layout, *args)
Error: [Errno 22] Invalid argument
Now printing a traceback.
Traceback (most recent call last):
File "tools/pyelf/elfweaver.py", line 79, in <module>
main(sys.argv)
File "/home/spex/src/okl4_3.0/tools/pyelf/weaver/main.py", line 108, in main
__commands__[args[1]](args[2:])
File "/home/spex/src/okl4_3.0/tools/pyelf/weaver/modify.py", line 284, in modify_cmd
elf.to_filename(outfile)
File "/home/spex/src/okl4_3.0/tools/pyelf/elf/core.py", line 712, in to_filename
self.to_file(File(filename, "wb"))
File "/home/spex/src/okl4_3.0/tools/pyelf/elf/core.py", line 706, in to_file
file_.seek(offset)
IOError: [Errno 22] Invalid argument
--------------------------------------------------------
strace was showing this (snippet showing only the probably relevant part):
[pid 15154] open("build/images/image.boot", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
[pid 15154] fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid 15154] write(2, "<frozen>:350: DeprecationWarning"..., 80<frozen>:350: DeprecationWarning:
struct integer overflow masking is deprecated
) = 80
[pid 15154] write(2, "<frozen>:592: DeprecationWarning"..., 80<frozen>:592: DeprecationWarning:
struct integer overflow masking is deprecated
) = 80
[pid 15154] brk(0x91b7000) = 0x91b7000
[pid 15154] fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 4), ...}) = 0
[pid 15154] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7af4000
[pid 15154] brk(0x9209000) = 0x9209000
[pid 15154] fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid 15154] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7af3000
[pid 15154] _llseek(3, 0, [0], SEEK_SET) = 0
[pid 15154] write(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\2\0(\0\1\0\0\0\0\0\3\240"..., 52) = 52
[pid 15154] _llseek(3, 18446744072368503520, 0xbfdcac50, SEEK_SET) = -1 EINVAL (Invalid argument)
[pid 15154] write(1, "Error: [Errno 22] Invalid argume"..., 35Error: [Errno 22] Invalid argument
) = 35
[pid 15154] close(3) = 0
--------------------------------------------------------
The first warning in the elfweaver output is a result of the following data
array, which indicates a broken e_shoff being used.
(2L, 40L, 1L, 2684551168L, 52, -1341048096L, 67108866, 52, 32, 15, 40, 64, 60)
From what I gathered so far, the elf file is read correctly, then some "magic"
happens (I assume the addresses are manipulated from virtual to physical ones) and
afterwards the modified sections are wrote back; however some of the e_shoff
calculations are wrong, leading to the broken offset, which in turn results in the
EINVAL from seek() / _llseek().
I've attached the "readelf -e" output of the image.elf file and the weaver.xml file
in question.
Ubuntu 8.04.1 system, Python 2.5.2 (using env+Python2.4 results in an error at structures.py:350
instead of just a warning).
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: readelf-e.txt
Url: http://lists.okl4.org/pipermail/developer/attachments/20081114/0612d650/attachment-0001.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: weaver.xml
Type: text/xml
Size: 9321 bytes
Desc: not available
Url : http://lists.okl4.org/pipermail/developer/attachments/20081114/0612d650/attachment-0001.bin
More information about the Developer
mailing list