Closed Bug 632920 Opened 9 years ago Closed 9 years ago

elfhack doesn't support R_ARM_THM_JMP24 and R_ARM_REL32 relocations

Categories

(Firefox Build System :: General, defect)

ARM
Linux
defect
Not set

Tracking

(blocking2.0 -)

RESOLVED FIXED
mozilla2.0b12
Tracking Status
blocking2.0 --- -

People

(Reporter: chrisccoulson, Assigned: glandium)

Details

(Whiteboard: [workaround: ac_add_options --disable-elf-hack])

Attachments

(5 files, 2 obsolete files)

I can't build Firefox 4.0 beta 11 on armel, as I get this build failure:

c++ -fno-rtti -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -Wno-long-long -g -fno-strict-aliasing -fshort-wchar -pthread -march=armv7-a -mthumb -Wa, -march=armv7-a -Wa, -mthumb -pipe -fexceptions  -DNDEBUG -DTRIMMED -Os -freorder-blocks -fomit-frame-pointer -finline-limit=50 -fPIC -shared -Wl,-z,defs -Wl,-h,test.so -o test.so test.o
===
=== If you get failures below, please file a bug describing the error
=== and your environment (compiler and linker versions), and use
=== --disable-elf-hack until this is fixed.
===
/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi/build/unix/elfhack/elfhack -b test.so
test.so: terminate called after throwing an instance of 'std::runtime_error'
  what():  Unsupported relocation type
Aborted
make[7]: *** [test.so] Error 134
make[7]: *** Deleting file `test.so'
make[7]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi/build/unix/elfhack'
make[6]: *** [libs] Error 2
make[6]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi/build/unix'
make[5]: *** [libs] Error 2
make[5]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi/build'
make[4]: *** [libs_tier_base] Error 2
make[4]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi'
make[3]: *** [tier_base] Error 2
make[3]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi'
make[2]: *** [default] Error 2
make[2]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla/objdir-arm-linux-gnueabi'
make[1]: *** [build] Error 2
make[1]: Leaving directory `/build/buildd/firefox-4.0~b11+build3+nobinonly/build-tree/mozilla'

See http://launchpadlibrarian.net/63748684/buildlog_ubuntu-natty-armel.firefox_4.0~b11%2Bbuild3%2Bnobinonly-0ubuntu1_FAILEDTOBUILD.txt.gz

As requested by glandium on IRC, here is the output of "readelf -d test.so.bak && objdump -r -d inject/*.o" from inside of build/unix/elfhack:

Dynamic section at offset 0x4ee0 contains 27 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [test.so]
 0x0000000c (INIT)                       0x1781
 0x0000000d (FINI)                       0x3fd1
 0x00000019 (INIT_ARRAY)                 0xcecc
 0x0000001b (INIT_ARRAYSZ)               12 (bytes)
 0x0000001a (FINI_ARRAY)                 0xced8
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x6ffffef5 (GNU_HASH)                   0x138
 0x00000005 (STRTAB)                     0x2a4
 0x00000006 (SYMTAB)                     0x184
 0x0000000a (STRSZ)                      183 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0xcfd8
 0x00000002 (PLTRELSZ)                   24 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x1768
 0x00000011 (REL)                        0x3a0
 0x00000012 (RELSZ)                      5064 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x00000018 (BIND_NOW)                   
 0x6ffffffb (FLAGS_1)                    Flags: NOW
 0x6ffffffe (VERNEED)                    0x380
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x35c
 0x6ffffffa (RELCOUNT)                   629
 0x00000000 (NULL)                       0x0

inject/arm-noinit.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <init>:
   0:	b5f0      	push	{r4, r5, r6, r7, lr}
   2:	2200      	movs	r2, #0
   4:	4c0c      	ldr	r4, [pc, #48]	; (38 <init+0x38>)
   6:	4b0d      	ldr	r3, [pc, #52]	; (3c <init+0x3c>)
   8:	480d      	ldr	r0, [pc, #52]	; (40 <init+0x40>)
   a:	447c      	add	r4, pc
   c:	447b      	add	r3, pc
   e:	4478      	add	r0, pc
  10:	e00d      	b.n	2e <init+0x2e>
  12:	185d      	adds	r5, r3, r1
  14:	1816      	adds	r6, r2, r0
  16:	4629      	mov	r1, r5
  18:	e003      	b.n	22 <init+0x22>
  1a:	680f      	ldr	r7, [r1, #0]
  1c:	18ff      	adds	r7, r7, r3
  1e:	f841 7b04 	str.w	r7, [r1], #4
  22:	6877      	ldr	r7, [r6, #4]
  24:	eb05 0787 	add.w	r7, r5, r7, lsl #2
  28:	42b9      	cmp	r1, r7
  2a:	d3f6      	bcc.n	1a <init+0x1a>
  2c:	3208      	adds	r2, #8
  2e:	5911      	ldr	r1, [r2, r4]
  30:	2900      	cmp	r1, #0
  32:	d1ee      	bne.n	12 <init+0x12>
  34:	bdf0      	pop	{r4, r5, r6, r7, pc}
  36:	bf00      	nop
  38:	0000002a 	.word	0x0000002a
			38: R_ARM_REL32	relhack
  3c:	0000002c 	.word	0x0000002c
			3c: R_ARM_REL32	elf_header
  40:	0000002e 	.word	0x0000002e
			40: R_ARM_REL32	relhack

inject/arm.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <init>:
   0:	e92d 43f0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, lr}
   4:	2400      	movs	r4, #0
   6:	4f10      	ldr	r7, [pc, #64]	; (48 <init+0x48>)
   8:	4b10      	ldr	r3, [pc, #64]	; (4c <init+0x4c>)
   a:	4e11      	ldr	r6, [pc, #68]	; (50 <init+0x50>)
   c:	447f      	add	r7, pc
   e:	447b      	add	r3, pc
  10:	447e      	add	r6, pc
  12:	e011      	b.n	38 <init+0x38>
  14:	eb03 0c05 	add.w	ip, r3, r5
  18:	eb04 0806 	add.w	r8, r4, r6
  1c:	4665      	mov	r5, ip
  1e:	e004      	b.n	2a <init+0x2a>
  20:	f8d5 9000 	ldr.w	r9, [r5]
  24:	4499      	add	r9, r3
  26:	f845 9b04 	str.w	r9, [r5], #4
  2a:	f8d8 9004 	ldr.w	r9, [r8, #4]
  2e:	eb0c 0989 	add.w	r9, ip, r9, lsl #2
  32:	454d      	cmp	r5, r9
  34:	d3f4      	bcc.n	20 <init+0x20>
  36:	3408      	adds	r4, #8
  38:	59e5      	ldr	r5, [r4, r7]
  3a:	2d00      	cmp	r5, #0
  3c:	d1ea      	bne.n	14 <init+0x14>
  3e:	e8bd 43f0 	ldmia.w	sp!, {r4, r5, r6, r7, r8, r9, lr}
  42:	f7ff bffe 	b.w	0 <original_init>
			42: R_ARM_THM_JUMP24	original_init
  46:	bf00      	nop
  48:	00000038 	.word	0x00000038
			48: R_ARM_REL32	relhack
  4c:	0000003a 	.word	0x0000003a
			4c: R_ARM_REL32	elf_header
  50:	0000003c 	.word	0x0000003c
			50: R_ARM_REL32	relhack
Hardware: x86_64 → ARM
Assignee: nobody → mh+mozilla
Summary: Fails to build on armel without --disable-elf-hack → elfhack doesn't support R_ARM_THM_JMP24 relocation
This one is not strictly necessary, but with the size of the function required for R_ARM_THM_JUMP24 relocations, it's better to do that.
Attachment #511364 - Flags: review?(tglek)
This allows to build Firefox with elfhack on Ubuntu's arm eabi port. There is no risk for other platforms, since we only add support for a new type of relocation. Just in case, I pushed to try as e9ba4419edd1.

Ubuntu could surely take the patches if that's not considered blocking.
blocking2.0: --- → ?
blocking2.0: ? → ---
Summary: elfhack doesn't support R_ARM_THM_JMP24 relocation → elfhack doesn't support R_ARM_THM_JMP24 and R_ARM_REL32 relocations
Attachment #511378 - Attachment is obsolete: true
Attachment #511463 - Flags: review?(tglek)
Attachment #511378 - Flags: review?(tglek)
Attached file test.so
Here's the test.so from a build with those patches
with the correct relocation function for R_ARM_REL32, it's better.
Attachment #511482 - Flags: review?(tglek)
Attachment #511463 - Attachment is obsolete: true
Attachment #511463 - Flags: review?(tglek)
Status: NEW → ASSIGNED
blocking2.0: --- → ?
Whiteboard: [workaround: ac_add_options --disable-elf-hack]
Comment on attachment 511364 [details] [diff] [review]
part 1 - Refactor relocations application to avoid error-prone duplication of code in elfhack

rubberstamp
Attachment #511364 - Flags: review?(tglek) → review+
Attachment #511482 - Flags: review?(tglek) → review+
blocking2.0: ? → -
Comment on attachment 511364 [details] [diff] [review]
part 1 - Refactor relocations application to avoid error-prone duplication of code in elfhack

This patch doesn't change any logic, but is required for the second one.
Attachment #511364 - Flags: approval2.0?
Comment on attachment 511482 [details] [diff] [review]
part 2 - Add support for R_ARM_THM_JUMP24 and R_ARM_REL32 relocations in elfhack

This patch doesn't change anything to elfhack (thus no risk), but adds support for two kinds of relocations that allow to build with elfhack on Ubuntu armel port.
Attachment #511482 - Flags: approval2.0?
Attachment #511364 - Flags: approval2.0? → approval2.0+
Attachment #511482 - Flags: approval2.0? → approval2.0+
http://hg.mozilla.org/mozilla-central/rev/c705e1cdb6ec
http://hg.mozilla.org/mozilla-central/rev/bc02cd2cfd98
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b12
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.