This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Wrong symbol index generated in object file



Hi all,


I'm using binutils port for DLX CPU (version 2.14 20030612).
There is a problem when assembling file in which are two code sections,
.text and another one e.g  .foo, and when function from one section calls
function from another section. When that file is assembled, wrong symbol
index is generated for the relocation related to the cross section call. For
every call of that kind, symbol index points to the name of the section
instead of called function from that section. This causes problem with
relocation calculation at linking time.

Here is the example of asm code::

.section .foo,"ax",@progbits
.align 2
.proc _foo_func_1
.global _foo_func_1
_foo_func_1:
nop
.endproc _foo_func_1

align 2
.proc _foo_func_2
.global _foo_func_2
_foo_func_2:
nop
.endproc _foo_func_2

.text
.align 2
.proc _text_func
.global _text func
_text_func:
jal _foo_func_2                           ;  calling function from another
section (calling  _foo_func_2  from section .foo)
.endproc _text func


Objdump of assembled source is like this: -----------------------------------------

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
 0 .text         00000004  00000000  00000000  00000034  2**2
                 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
 1 .data         00000000  00000000  00000000  00000038  2**0
                 CONTENTS, ALLOC, LOAD, DATA
 2 .bss          00000000  00000000  00000000  00000038  2**0
                 ALLOC
 3 .foo    00000008  00000000  00000000  00000038  2**2
                 CONTENTS, ALLOC, LOAD, READONLY, CODE
SYMBOL TABLE:
00000000 l    d  .text  00000000
00000000 l    d  .data  00000000
00000000 l    d  .bss   00000000
00000000 l    d  .foo     00000000
00000000 g       .foo     00000000   _foo_func_1
00000004 g       .foo     00000000   _foo_func_2
00000000 g       .text  00000000 _text_func


Disassembly of section .text:


00000000 <_text_func>:
  0:   0c 00 00 00     jal     0x00000004
                               0: R_DLX_RELOC_26_PCREL  .foo       <--- you
can see here that symbol index from object

                             file points to the section name (.foo) instead
of called function name (_func2).

                             I've found in obj file that symbol index is 4
instead of 6 for this relocation.

Disassembly of section .data:

Disassembly of section .foo:

00000000 <_foo_func_1>:
  0:   54 00 00 00     nop

00000004 <_foo_func_2>:
  4:   54 00 00 00     nop


As you can see, symbol index which references to the necessary symbol (_foo_func2) for this relocation is wrong. That causes wrong relocation calculation at linking time. Can you please tell me where to look in binutils code to find where symbol index gets wrong value. Is that in DLX related part of code or that can be bug in this version of .binutils

Thanks in advance and best regards,
Nemanja Popov


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]