This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
binutils gas patch to fix incorrect symbol flags
- To: binutils at sourceware dot cygnus dot com, tdel at mail dot wrs dot com
- Subject: binutils gas patch to fix incorrect symbol flags
- From: Thomas de Lellis <tdel at windriver dot com>
- Date: Mon, 24 Jan 2000 16:58:58 -0800
Objdump was found to be dumping raw hex bytes in the disassembly
listing. The problem was traced back to symbol flags being set
incorrectly in the assembler for labels in code sections. The
routine that handles this now attempts to differentiate between
code and data sections when setting flags.
======================================================================
2000-01-18 Thomas de Lellis <tdel@windriver.com>
* config/obj-elf.c (elf_frob_symbol): If an untyped
symbol resides in a CODE section, flag it as a
function symbol. Otherwise, flag it as a data symbol.
(Allows objdump to generate disassembly listings of
code rather than simply dumping hex bytes.)
======================================================================
*** obj-elf.c@@/main/3 Mon Oct 4 13:17:32 1999
--- obj-elf.c Mon Jan 24 16:24:41 2000
***************
*** 22,27 ****
--- 22,28 ----
#include "as.h"
#include "subsegs.h"
#include "obstack.h"
+ #include "struc-symbol.h"
#ifndef ECOFF_DEBUGGING
#define ECOFF_DEBUGGING 0
*************** elf_frob_symbol (symp, puntp)
*** 1627,1640 ****
symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
! #ifdef TC_PPC
! /* Frob the PowerPC, so that the symbol always has object type
if it is not some other type. VxWorks needs this. */
if ((symbol_get_bfdsym (symp)->flags
! & (BSF_FUNCTION | BSF_FILE | BSF_SECTION_SYM)) == 0
&& S_IS_DEFINED (symp))
! symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
! #endif
}
void
--- 1628,1651 ----
symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif
! /* Frob all, so that the symbol always has a type
if it is not some other type. VxWorks needs this. */
+
+ /* We also try to make a half-intellegent guess as to the
+ type of the symbol. If the untyped assembly label is in a
+ CODE section, flag it as a FUNCTION so that objdump will
+ dump in mnemonic mode. Else if not in a CODE section go
+ ahead and assume it's an OBJECT type. */
+
if ((symbol_get_bfdsym (symp)->flags
! & (BSF_FUNCTION | BSF_OBJECT | BSF_FILE | BSF_SECTION_SYM)) == 0
&& S_IS_DEFINED (symp))
! {
! if (symp->bsym->section->flags & SEC_CODE)
! symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION;
! else
! symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
! }
}
void
======================================================================
TESTCASE AND RESULTS
> cat ttt.s
.text
.global test
.type test,function
test:
nop
nop
nop
.Lxxxx:
nop
nop
nop
test2:
nop
nop
nop
test25:
nop
nop
nop
test3:
nop
nop
nop
test35:
nop
nop
nop
.type test4,object
test4:
.long 1
.long 2
.long 3
test5:
nop
nop
nop
.data
l1:
.long 0
.L2:
.long 0
.type l3,function
l3:
nop
nop
.type l4,object
l4:
nop
nop
PREVIOUS FAILURE MODE ==================================================
> ./test
+ asppc -o ttt.o ttt.s
+ objdumpppc -d ttt.o
ttt.o: file format elf32-powerpc
Disassembly of section .text:
00000000 <test>:
0: 60 00 00 00 nop
4: 60 00 00 00 nop
8: 60 00 00 00 nop
c: 60 00 00 00 nop
10: 60 00 00 00 nop
14: 60 00 00 00 nop
00000018 <test2>:
18: 60 00 00 00 60 00 00 00 60 00 00 00 `...`...`...
00000024 <test25>:
24: 60 00 00 00 60 00 00 00 60 00 00 00 `...`...`...
00000030 <test3>:
30: 60 00 00 00 60 00 00 00 60 00 00 00 `...`...`...
0000003c <test35>:
3c: 60 00 00 00 60 00 00 00 60 00 00 00 `...`...`...
00000048 <test4>:
48: 00 00 00 01 00 00 00 02 00 00 00 03 ............
00000054 <test5>:
54: 60 00 00 00 60 00 00 00 60 00 00 00 `...`...`...
PASS ===================================================
> ./test
+ asppc -o ttt.o ttt.s
+ objdumpppc -d ttt.o
ttt.o: file format elf32-powerpc
Disassembly of section .text:
00000000 <test>:
0: 60 00 00 00 nop
4: 60 00 00 00 nop
8: 60 00 00 00 nop
c: 60 00 00 00 nop
10: 60 00 00 00 nop
14: 60 00 00 00 nop
00000018 <test2>:
18: 60 00 00 00 nop
1c: 60 00 00 00 nop
20: 60 00 00 00 nop
00000024 <test25>:
24: 60 00 00 00 nop
28: 60 00 00 00 nop
2c: 60 00 00 00 nop
00000030 <test3>:
30: 60 00 00 00 nop
34: 60 00 00 00 nop
38: 60 00 00 00 nop
0000003c <test35>:
3c: 60 00 00 00 nop
40: 60 00 00 00 nop
44: 60 00 00 00 nop
00000048 <test4>:
48: 00 00 00 01 00 00 00 02 00 00 00 03 ............
00000054 <test5>:
54: 60 00 00 00 nop
58: 60 00 00 00 nop
5c: 60 00 00 00 nop