Bug 13321 - Gold creates mixed Thumb/ARM files that objdump -d doesn't understand
Summary: Gold creates mixed Thumb/ARM files that objdump -d doesn't understand
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Doug Kwan
URL:
Keywords:
: 13322 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-19 16:27 UTC by Mike Hommey
Modified: 2016-03-27 18:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Hommey 2011-10-19 16:27:38 UTC
I haven't looked exactly why this happens but here is the problem:

$ cat <<EOF >test.c
#include <stdio.h>
void foo() {
  printf("foo\n");
}
EOF
$ gcc -o test.so -shared test.c -mthumb -fPIC -Os -march=armv7-a
$ objdump -d test.so
test.so:     file format elf32-littlearm


Disassembly of section .plt:

000001d0 <.plt>:
 1d0:	e52de004 	.word	0xe52de004
 1d4:	e59fe004 	.word	0xe59fe004
 1d8:	e08fe00e 	.word	0xe08fe00e
 1dc:	e5bef008 	.word	0xe5bef008
 1e0:	000010c8 	.word	0x000010c8
 1e4:	e28fc600 	.word	0xe28fc600
 1e8:	e28cca01 	.word	0xe28cca01
 1ec:	e5bcf0c8 	.word	0xe5bcf0c8

Disassembly of section .text:

000001f0 <foo>:
 1f0:	4801      	ldr	r0, [pc, #4]	; (1f8 <foo+0x8>)
 1f2:	4478      	add	r0, pc
 1f4:	f000 b802 	b.w	1fc <foo+0xc>
 1f8:	00000016 	.word	0x00000016
 1fc:	46c04778 	.word	0x46c04778
 200:	e59fc000 	.word	0xe59fc000
 204:	e08cf00f 	.word	0xe08cf00f
 208:	ffffffd8 	.word	0xffffffd8

With GNU ld:
$ gcc -o test.so -shared test.c -mthumb -fPIC -Os -march=armv7-a
$ objdump -d test.so
test.so:     file format elf32-littlearm


Disassembly of section .plt:

00000260 <.plt>:
 260:	e52de004 	push	{lr}		; (str lr, [sp, #-4]!)
 264:	e59fe004 	ldr	lr, [pc, #4]	; 270 <foo-0x14>
 268:	e08fe00e 	add	lr, pc, lr
 26c:	e5bef008 	ldr	pc, [lr, #8]!
 270:	000080b4 	.word	0x000080b4
 274:	4778      	bx	pc
 276:	46c0      	nop			; (mov r8, r8)
 278:	e28fc600 	add	ip, pc, #0
 27c:	e28cca08 	add	ip, ip, #32768	; 0x8000
 280:	e5bcf0b0 	ldr	pc, [ip, #176]!	; 0xb0

Disassembly of section .text:

00000284 <foo>:
 284:	4801      	ldr	r0, [pc, #4]	; (28c <foo+0x8>)
 286:	4478      	add	r0, pc
 288:	f7ff bff4 	b.w	274 <foo-0x10>
 28c:	00000006 	.word	0x00000006
Comment 1 Sourceware Commits 2015-02-11 07:20:02 UTC
The master branch has been updated by Will Newton <willnewton@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=07f107f306e422497915e62f6c3d3d6d7b20e8e1

commit 07f107f306e422497915e62f6c3d3d6d7b20e8e1
Author: Will Newton <will.newton@linaro.org>
Date:   Mon Feb 9 17:11:54 2015 +0800

    gold/arm.cc: Output mapping symbol for PLT code
    
    Output an ARM state mapping symbol at the start of the PLT. With the
    current code objdump will fail to disassemble the PLT that gold
    creates.
    
    gold/ChangeLog:
    
    2015-02-11  Will Newton  <will.newton@linaro.org>
    
    	PR gold/13321
    	* arm.cc (Target_arm::make_plt_section): Create an ARM
    	state mapping symbol at the start of the PLT.
Comment 2 Cary Coutant 2016-03-27 18:27:25 UTC
Fixed.
Comment 3 Cary Coutant 2016-03-27 18:30:23 UTC
*** Bug 13322 has been marked as a duplicate of this bug. ***