[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Gcl-devel] BFD related issues - belated reply.
From: |
Mike Thomas |
Subject: |
RE: [Gcl-devel] BFD related issues - belated reply. |
Date: |
Thu, 8 Jan 2004 15:48:15 +1000 |
Hi Aurelien.
| I've tried compiling bfd using cygwin but without success yet.
Don't forget we are using MinGW32 (MSYS hosted) for GCL.
|
| The howto structure being in a bad shape (none of the fields seem
| alright, although they ought to), could it be possible to set a
| breakpoint in bfd_generic_get_relocated_section_contents and try
| tracing bfd_canonicalize_reloc ?
Yes. It looks pretty bad there too (some pointers out of range and some set
to 0xbaadf00d as shown below.
============================================================================
=
Breakpoint 2, bfd_generic_get_relocated_section_contents (abfd=0x67ff20,
link_info=0x455300, link_order=0x455040, data=0x5d3ef0 "",
relocateable=false, symbols=0x22fed4) at reloc.c:3724
3724 bfd *input_bfd = link_order->u.indirect.section->owner;
(gdb) n
3727 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
input_section)
;
(gdb) n
3724 bfd *input_bfd = link_order->u.indirect.section->owner;
(gdb) n
3727 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
input_section)
;
(gdb) n
3724 bfd *input_bfd = link_order->u.indirect.section->owner;
(gdb) n
3727 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
input_section)
;
(gdb) n
3731 if (reloc_size < 0)
(gdb) n
3727 long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
input_section)
;
(gdb) n
3731 if (reloc_size < 0)
(gdb) n
3734 reloc_vector = (arelent **) bfd_malloc ((bfd_size_type)
reloc_size);
(gdb) n
3735 if (reloc_vector == NULL && reloc_size != 0)
(gdb) n
3739 if (!bfd_get_section_contents (input_bfd,
(gdb) n
3747 input_section->_cooked_size = input_section->_raw_size;
(gdb) n
3748 input_section->reloc_done = true;
(gdb) n
3747 input_section->_cooked_size = input_section->_raw_size;
(gdb) n
3750 reloc_count = bfd_canonicalize_reloc (input_bfd,
(gdb) s
bfd_canonicalize_reloc (abfd=0x67ff20, asect=0xbfd244, location=0x5d3f90,
symbols=0x22fed4) at bfd.c:612
612 if (abfd->format != bfd_object)
(gdb) p *abfd
$23 = {filename = 0x3d2cd4 "./gazonk0.o", xvec = 0x4177b0,
iostream = 0x77c5ace0, cacheable = true, target_defaulted = true,
lru_prev = 0x67ff20, lru_next = 0x67ff20, where = 332, opened_once =
false,
mtime_set = false, mtime = 0, ifd = 0, format = bfd_object,
direction = read_direction, flags = 57, origin = 0,
output_has_begun = false, section_htab = {table = 0x3d5038, size = 4051,
newfunc = 0x408dd0 <bfd_section_hash_newfunc>, memory = 0x67ffd0},
sections = 0xbfd244, section_tail = 0xbfd4b0, section_count = 5,
start_address = 0, symcount = 15, outsymbols = 0x0, arch_info = 0x413d10,
arelt_data = 0x0, my_archive = 0x0, next = 0x0, archive_head = 0x0,
has_armap = false, link_next = 0x0, archive_pass = 0, tdata = {
aout_data = 0x608e70, aout_ar_data = 0x608e70, oasys_obj_data =
0x608e70,
oasys_ar_data = 0x608e70, coff_obj_data = 0x608e70,
pe_obj_data = 0x608e70, xcoff_obj_data = 0x608e70,
ecoff_obj_data = 0x608e70, ieee_data = 0x608e70, ieee_ar_data =
0x608e70,
srec_data = 0x608e70, ihex_data = 0x608e70, tekhex_data = 0x608e70,
elf_obj_data = 0x608e70, nlm_obj_data = 0x608e70, bout_data = 0x608e70,
mmo_data = 0x608e70, sun_core_data = 0x608e70, sco5_core_data =
0x608e70,
trad_core_data = 0x608e70, som_data = 0x608e70, hpux_core_data =
0x608e70,
hppabsd_core_data = 0x608e70, sgi_core_data = 0x608e70,
lynx_core_data = 0x608e70, osf_core_data = 0x608e70,
cisco_core_data = 0x608e70, versados_data = 0x608e70,
netbsd_core_data = 0x608e70, any = 0x608e70}, usrdata = 0x0,
---Type <return> to continue, or q <return> to quit---
memory = 0x3d2d48}
(gdb) p *asect
$24 = {name = 0xbaadf00d <Address 0xbaadf00d out of bounds>, id
= -1163005939,
index = -1163005939, next = 0xbaadf00d, flags = 3131961357,
user_set_vma = 1, reloc_done = 0, linker_mark = 1, linker_has_input = 1,
gc_mark = 0, segment_mark = 0, vma = 3131961357, lma = 3131961357,
_cooked_size = 3131961357, _raw_size = 3131961357,
output_offset = 3131961357, output_section = 0xabababab,
alignment_power = 2880154539, relocation = 0xfeeefeee, orelocation = 0x0,
reloc_count = 0, filepos = 589828, rel_filepos = -17955839,
line_filepos = 3998104, userdata = 0x3d0198,
contents = 0xfeeefeee <Address 0xfeeefeee out of bounds>,
lineno = 0xfeeefeee, lineno_count = 4277075694, entsize = 4277075694,
comdat = 0x401ff, moving_line_filepos = 1574657, target_index = 5767240,
used_by_bfd = 0x0, constructor_chain = 0x6153665f, owner = 0x636f6c6c,
symbol = 0x5f657461, symbol_ptr_ptr = 0x746e6f63,
link_order_head = 0x6f756769, link_order_tail = 0x705f7375}
(gdb) p *arelent
A parse error in expression, near `'.
(gdb) p *location
$25 = (arelent *) 0xbaadf00d
(gdb) p location
$26 = (arelent **) 0x5d3f90
(gdb) p **location
Cannot access memory at address 0xbaadf00d
(gdb) u
618 return BFD_SEND (abfd, _bfd_canonicalize_reloc,
(gdb) info frame
Stack level 0, frame at 0x22fe40:
eip = 0x402eef in bfd_canonicalize_reloc (bfd.c:618); saved eip 0x40f8de
called by frame at 0x22fe80
source language c.
Arglist at 0x22fe38, args: abfd=0x67ff20, asect=0xbfd244,
location=0x5d3f90,
symbols=0x22fed4
Locals at 0x22fe38, Previous frame's sp is 0x22fe40
Saved registers:
ebp at 0x22fe38, eip at 0x22fe3c
(gdb) up
#1 0x0040f8de in bfd_generic_get_relocated_section_contents (abfd=0x67ff20,
link_info=0x455300, link_order=0x455040, data=0x5d3ef0 "\2038\030h",
relocateable=false, symbols=0x22fed4) at reloc.c:3750
3750 reloc_count = bfd_canonicalize_reloc (input_bfd,
(gdb) info frame
Stack level 1, frame at 0x22fe80:
eip = 0x40f8de in bfd_generic_get_relocated_section_contents
(reloc.c:3750);
saved eip 0x4033f5
called by frame at 0x22feb0, caller of frame at 0x22fe40
source language c.
Arglist at 0x22fe78, args: abfd=0x67ff20, link_info=0x455300,
link_order=0x455040, data=0x5d3ef0 "\2038\030h", relocateable=false,
symbols=0x22fed4
Locals at 0x22fe78, Previous frame's sp is 0x22fe80
Saved registers:
ebx at 0x22fe6c, ebp at 0x22fe78, esi at 0x22fe70, edi at 0x22fe74,
eip at 0x22fe7c
(gdb) p *abfd
$27 = {filename = 0x3d2cd4 "./gazonk0.o", xvec = 0x4177b0,
iostream = 0x77c5ace0, cacheable = true, target_defaulted = true,
lru_prev = 0x67ff20, lru_next = 0x67ff20, where = 332, opened_once =
false,
mtime_set = false, mtime = 0, ifd = 0, format = bfd_object,
direction = read_direction, flags = 57, origin = 0,
output_has_begun = false, section_htab = {table = 0x3d5038, size = 4051,
newfunc = 0x408dd0 <bfd_section_hash_newfunc>, memory = 0x67ffd0},
sections = 0xbfd244, section_tail = 0xbfd4b0, section_count = 5,
start_address = 0, symcount = 15, outsymbols = 0x0, arch_info = 0x413d10,
arelt_data = 0x0, my_archive = 0x0, next = 0x0, archive_head = 0x0,
has_armap = false, link_next = 0x0, archive_pass = 0, tdata = {
aout_data = 0x608e70, aout_ar_data = 0x608e70, oasys_obj_data =
0x608e70,
oasys_ar_data = 0x608e70, coff_obj_data = 0x608e70,
pe_obj_data = 0x608e70, xcoff_obj_data = 0x608e70,
ecoff_obj_data = 0x608e70, ieee_data = 0x608e70, ieee_ar_data =
0x608e70,
srec_data = 0x608e70, ihex_data = 0x608e70, tekhex_data = 0x608e70,
elf_obj_data = 0x608e70, nlm_obj_data = 0x608e70, bout_data = 0x608e70,
mmo_data = 0x608e70, sun_core_data = 0x608e70, sco5_core_data =
0x608e70,
trad_core_data = 0x608e70, som_data = 0x608e70, hpux_core_data =
0x608e70,
hppabsd_core_data = 0x608e70, sgi_core_data = 0x608e70,
lynx_core_data = 0x608e70, osf_core_data = 0x608e70,
cisco_core_data = 0x608e70, versados_data = 0x608e70,
netbsd_core_data = 0x608e70, any = 0x608e70}, usrdata = 0x0,
---Type <return> to continue, or q <return> to quit---
memory = 0x3d2d48}
(gdb) p *symbols
$28 = (asymbol *) 0xbaadf00d
(gdb) p symbols
$29 = (asymbol **) 0x5d3f90
(gdb)
============================================================================
=
|
| bfd_perform_relocation is called for every relocation entry. Does the
| problem appear for the very first relocation entry ?
Yes:
============================================================================
=
DOING RELOCATIONS
s->name .text, s->flags = 237
About to get reloc section contents
obj_bfd = 67ff20, section .text, s->output_section = bfd244, q = 22fed4
Breakpoint 2, bfd_generic_get_relocated_section_contents (abfd=0x67ff20,
link_info=0x455300, link_order=0x455040, data=0x5d3ef0 "",
relocateable=false, symbols=0x22fed4) at reloc.c:3724
3724 bfd *input_bfd = link_order->u.indirect.section->owner;
(gdb) c
Continuing.
Breakpoint 3, bfd_perform_relocation (abfd=0x67ff20, reloc_entry=0x609d10,
data=0x5d3ef0, input_section=0xbfd244, output_bfd=0x0,
error_message=0x22fe68) at reloc.c:595
595 bfd_reloc_status_type flag = bfd_reloc_ok;
(gdb) c
Continuing.
Breakpoint 1, bfd_perform_relocation (abfd=0x67ff20, reloc_entry=0x609d10,
data=0x5d3ef0, input_section=0xbfd244, output_bfd=0x0,
error_message=0x22fe68) at reloc.c:624
624 cont = howto->special_function (abfd, reloc_entry, symbol,
data,
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
bfd_getl32 (addr=0x67ff20 "+,=") at libbfd.c:1058
1058 v |= (unsigned long) addr[1] << 8;
(gdb)
============================================================================
=
| Moreover, would it
| be possible to examine the contents of **reloc_entry->sym_ptr_ptr ?
============================================================================
=
Breakpoint 3, bfd_perform_relocation (abfd=0x67ff20, reloc_entry=0x609d10,
data=0x5d3ef0, input_section=0xbfd244, output_bfd=0x0,
error_message=0x22fe68) at reloc.c:595
595 bfd_reloc_status_type flag = bfd_reloc_ok;
(gdb) p reloc_entry->sym_ptr_ptr
$30 = (struct symbol_cache_entry **) 0x22fee8
(gdb) p *reloc_entry->sym_ptr_ptr
$31 = (struct symbol_cache_entry *) 0xda7c8c
(gdb) p **reloc_entry->sym_ptr_ptr
$32 = {the_bfd = 0x67ff20, name = 0x609bb0 ".data", value = 0, flags = 1,
section = 0xbfd2dc, udata = {p = 0x0, i = 0}}
(gdb) p *reloc_entry
$33 = {sym_ptr_ptr = 0x22fee8, address = 4288856340, addend = 4288856224,
howto = 0x414088}
(gdb) p *reloc_entry->howto
$34 = {type = 0, rightshift = 0, size = 0, bitsize = 0, pc_relative =
720905,
bitpos = 786689, complain_on_overflow = complain_overflow_dont,
special_function = 0, name = 0x0, partial_inplace = false, src_mask = 0,
dst_mask = 0, pcrel_offset = false}
============================================================================
=
Best wishes
Mike Thomas