Commit 9a0dc1e0 authored by rsesek@chromium.org's avatar rsesek@chromium.org

sandbox: Remove a TEXTREL on Linux ARM.

On Android, the sandbox logic is put into a shared library and the linker errors
out on having a TEXTREL.

The LDR pseudo-instruction directs the assembler to place the address of the
label in a "literal pool"[1], and then use a PC-relative load from that pool to
get the address during execution. The pool is responsible for generating
the R_ARM_RELATIVE TEXTREL.

Using the ADR instruction[2] does not produce the TEXTREL. This instruction
directs the assembler to calculate the PC-relative address to the label using an
immediate.

The text makes this difference more clear:

...
   8:   4805            ldr     r0, [pc, #20]   ; (20 <SyscallAsm+0x20>)
   a:   e007            b.n     1c <SyscallAsm+0x1c>
...
  1c:   bd80            pop     {r7, pc}
  1e:   0000            .short  0x0000
  20:   0000001c        .word   0x0000001c

Versus:

...
   8:   4804            ldr     r0, [pc, #16]   ; (1c <SyscallAsm+0x1c>)
   a:   e007            b.n     1c <SyscallAsm+0x1c>
...
  1c:   bd80            pop     {r7, pc}
  1e:   bf00            nop


[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0041c/Babbfdih.html
[2] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0040d/Cihdhgbe.html

BUG=308763

Review URL: https://codereview.chromium.org/119453002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242141 0039d316-1c4b-4281-b951-d872f2087c98
parent bd672caf
......@@ -77,11 +77,6 @@
'dependencies': [
'../testing/android/native_test.gyp:native_test_native_code',
],
'ldflags!': [
# Remove warnings about text relocations, to prevent build
# failure.
'-Wl,--warn-shared-textrel'
],
}],
],
},
......
......@@ -143,7 +143,7 @@ namespace sandbox {
// used as a marker that BPF code inspects.
"cmp r0, #0\n"
"bge 1f\n"
"ldr r0, =2f\n"
"adr r0, 2f\n"
"b 2f\n"
// We declared (almost) all clobbered registers to the compiler. On
// ARM there is no particular register pressure. So, we can go
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment