Skip site navigation (1)Skip section navigation (2)
Date:      02 Feb 2002 14:29:55 +0100
From:      Dag-Erling Smorgrav <des@ofug.org>
To:        John Hay <jhay@icomtek.csir.co.za>
Cc:        obrien@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/contrib/binutils
Message-ID:  <xzpwuxwxb8s.fsf@flood.ping.uio.no>
In-Reply-To: <xzpu1t0ywvj.fsf@flood.ping.uio.no>
References:  <200202020459.g124xdL87420@zibbi.icomtek.csir.co.za> <xzpu1t0ywvj.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smorgrav <des@ofug.org> writes:
> ...which is obviously wrong.  It seems the load address I computed for
> ld-elf.so.1 (MAXDSIZ + pngtest data offset + ld-elf text offset) is
> off by about 1500 bytes, though I have no idea why.

Doh!  I forgot to round down to the nearest page boundary, like
imgact_elf does:

% objdump -h pngtest | grep Name
Idx Name          Size      VMA       LMA       File off  Algn
% objdump -h pngtest | fgrep ' .data'
 12 .data         00000060  0804c6e0  0804c6e0  000036e0  2**2
% objdump -h /usr/libexec/ld-elf.so.1 | fgrep ' .text'
  5 .text         0000e660  00003238  00003238  00003238  2**2
% gdb pngtest
[...]
(gdb) run
Starting program: /usr/ports/graphics/png/work/libpng-1.2.1/pngtest

Program received signal SIGBUS, Bus error.
0x28053212 in ?? ()
(gdb) add-symbol-file /usr/libexec/ld-elf.so.1 (512*1024*1024 + 0x0804c000 + 0x00003238)
add symbol table from file "/usr/libexec/ld-elf.so.1" at text_addr = 0x2804f238?
(y or n) y
Reading symbols from /usr/libexec/ld-elf.so.1...done.
(gdb) up 0
#0  0x28053212 in reloc_non_plt (obj=0x28065100, obj_rtld=0x28061840)
    at /usr/src/libexec/rtld-elf/i386/reloc.c:196
196                     *where += (Elf_Addr) obj->relocbase;
(gdb) p/x *rel
$1 = {r_offset = 0x1c025, r_info = 0x8}
(gdb) p/x *obj
$2 = {magic = 0x0, version = 0x0, next = 0x28065200, path = 0x28064020,
  refcount = 0x1, dl_refcount = 0x0, mapbase = 0x2806b000, mapsize = 0x22000,
  textsize = 0x21000, vaddrbase = 0x0, relocbase = 0x2806b000,
  dynamic = 0x2808c788, entry = 0x28070674, phdr = 0x0, phsize = 0x0,
  interp = 0x0, pltgot = 0x2808c850, rel = 0x2806ef40, relsize = 0x140,
  rela = 0x0, relasize = 0x0, pltrel = 0x2806f080, pltrelsize = 0x748,
  pltrela = 0x0, pltrelasize = 0x0, symtab = 0x2806bb34, strtab = 0x2806d524,
  strsize = 0x1a1a, buckets = 0x2806b09c, nbuckets = 0x107,
  chains = 0x2806b4b8, nchains = 0x19f, rpath = 0x0, needed = 0x28067040,
  init = 0x2806f7c8, fini = 0x28088618, mainprog = 0x0, rtld = 0x0,
  textrel = 0x0, symbolic = 0x0, traced = 0x0, jmpslots_done = 0x0,
  init_done = 0x0, linkmap = {l_addr = 0x2806b000, l_name = 0x28064020,
    l_ld = 0x2808c788, l_next = 0x28065298, l_prev = 0x28065098}, dldags = {
    stqh_first = 0x0, stqh_last = 0x280651ac}, dagmembers = {stqh_first = 0x0,
    stqh_last = 0x280651b4}, dev = 0x7404, ino = 0x59d45, priv = 0x0}
(gdb) p/x where
$3 = 0x28087025
(gdb) p/x *where
$4 = 0x21760
(gdb) p/x obj->relocbase
$5 = 0x2806b000
(gdb) p/x (*where + (Elf_Addr)obj->relocbase)
$6 = 0x2808c760
(gdb) p/x *(*where + (Elf_Addr)obj->relocbase)
$7 = 0xffffff

That still doesn't tell us *why* it dumped core - and SIGBUS can mean
a lot of things...  Most likely reason here is that *where isn't
writeable, though it *should* be, but I don't know why, and I don't
know why no other code is affected.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpwuxwxb8s.fsf>