ld ignores the -fno-pie option and produces the same error. Presumably
it's because I'm trying to build a static executable.
I've tried passing every option I can think of to ld, but I can't work
it out. The output from the assembler is fine, can be linked on a machine
running 5.7, and the resulting binary executes on a 5.8 box.
I'm not sure where else to look...
On Fri, Dec 04, 2015 at 03:55:09PM -0700, Theo de Raadt wrote:
Most architectures went to 'static PIE' by default in 5.8.
You will probably need something like -fno-pie.
The entire exercise of writing asm which bootstraps without
the c runtime means you are very much on your own.
This assembled and linked without problems on 5.7-release, but now when
I try it on 5.8-release, I get an error:
$ as -o charset.o charset.S
$ ld -Bstatic charset.o
ld: charset.o: relocation R_X86_64_32S against `a local symbol' can not
be used when making a shared object; recompile with -fPIC
charset.o: could not read symbols: Bad value
What's changed?
charset.S is fairly trivial:
.section ".note", "a"
.p2align 2
.long 0x08
.long 0x04
.long 0x01
.ascii "OpenBSD\0"
.long 0x00
.p2align 2
.section .data
bytestore: .quad 0x20
welcome: .ascii "Characterset generator by Tati Chevron, 27/4/2015."
.byte 0x0A
newline: .quad 0x0A
.section .text
.globl _start
_start:
mov $welcome, %rsi
mov $1, %rdi
mov $4, %rax
mov $53, %rdx
syscall
_loop:
push bytestore
pop %rax
cmp $0xFF, %rax
jz _exit
cmp $0x80, %rax
jnz _skip
call _nl
push bytestore
pop %rax
_skip:
inc %rax
mov %rax, bytestore
mov $4, %rax
mov $1, %rdi
mov $bytestore, %rsi
mov $1, %rdx
syscall
jmp _loop
_exit:
call _nl
mov $1, %rdi
mov $1, %rax
syscall
_nl:
mov $4, %rax
mov $1, %rdi
mov $newline, %rsi
mov $1, %rdx
syscall
ret
--
Tati Chevron
Perl and FORTRAN specialist.
SWABSIT development and migration department.
http://www.swabsit.com
--
Tati Chevron
Perl and FORTRAN specialist.
SWABSIT development and migration department.
http://www.swabsit.com