From: kettenis Date: Mon, 5 Dec 2022 07:49:07 +0000 (+0000) Subject: Add linker script for hppa. The crucial bit is that hppa needs an extra X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7e53a3c9de40871999d818f6a139f767e373291e;p=openbsd Add linker script for hppa. The crucial bit is that hppa needs an extra segment for .plt/.got which needs to be placed correctly. ok deraadt@ --- diff --git a/libexec/ld.so/hppa/Makefile.inc b/libexec/ld.so/hppa/Makefile.inc index 7e09624fb0a..9b81691c9ba 100644 --- a/libexec/ld.so/hppa/Makefile.inc +++ b/libexec/ld.so/hppa/Makefile.inc @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.6 2022/01/31 05:43:22 guenther Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2022/12/05 07:49:07 kettenis Exp $ CFLAGS += -fpic AFLAGS += -fpic +LD_SCRIPT = ${.CURDIR}/${MACHINE_CPU}/ld.script # extract components from libgcc.a MDOBJ= _dyncall.o _remU.o _remI.o _divI.o _divU.o _div_const.o diff --git a/libexec/ld.so/hppa/ld.script b/libexec/ld.so/hppa/ld.script index e69de29bb2d..db529220f7e 100644 --- a/libexec/ld.so/hppa/ld.script +++ b/libexec/ld.so/hppa/ld.script @@ -0,0 +1,77 @@ +PHDRS +{ + rodata PT_LOAD FILEHDR PHDRS FLAGS (4); + text PT_LOAD; + btext PT_LOAD FLAGS (0x08000005); + pltgot PT_LOAD; + data PT_LOAD; + random PT_OPENBSD_RANDOMIZE; + relro PT_GNU_RELRO; + dynamic PT_DYNAMIC; + note PT_NOTE; +} + +SECTIONS +{ + /* RODATA */ + . = 0 + SIZEOF_HEADERS; + .dynsym : { *(.dynsym) } :rodata + .gnu.hash : { *(.gnu.hash) } :rodata + .dynstr : { *(.dynstr) } :rodata + .rodata : { *(.rodata .rodata.*) } :rodata + .eh_frame : { *(.eh_frame) } :rodata + + /* TEXT */ + . = ALIGN(0x1000); + .text : { *(.text .text.*) } :text + . = ALIGN(0x1000); + .boot.text : + { + . = ALIGN(0x1000); + boot_text_start = .; + *(.boot.text) + . = ALIGN(0x1000); + boot_text_end = .; + } :btext + + /* PLT and GOT */ + . = ALIGN(0x1000); + .plt : { *(.plt) } :pltgot + .got : { *(.got.plt) *(.got) } :pltgot + + /* RELRO DATA */ + . = DATA_SEGMENT_ALIGN (0x1000, 0x1000); + .openbsd.randomdata : + { + *(.openbsd.randomdata .openbsd.randomdata.*) + } :data :relro :random + .data.rel.ro : { *(.data.rel.ro.local*) *(.data.rel.ro*) } :data :relro + .dynamic : { *(.dynamic) } :data :relro :dynamic + . = DATA_SEGMENT_RELRO_END (0, .); + + /* BOOTDATA */ + . = ALIGN(0x1000); + boot_data_start = .; + .rela.dyn : + { + *(.rela.text .rela.text.*) + *(.rela.rodata .rela.rodata.*) + *(.rela.data .rela.data.*) + *(.rela.got) + *(.rela.bss .rela.bss.*) + } :data +/* XXX .rela.plt is unused but cannot delete: ld.bfd zeros DT_RELASZ then! */ + .rela.plt : { *(.rela.plt) } :data + .hash : { *(.hash) } :data + .note : { *(.note.openbsd.*) } :data :note + .boot.data : { *(.boot.data .boot.data.*) } :data + boot_data_end = .; + + /* DATA */ + . = ALIGN(0x1000); + .data : { *(.data .data.*) } :data + .bss : { *(.dynbss) *(.bss .bss.*) *(COMMON) } :data + . = DATA_SEGMENT_END (.); + + /DISCARD/ : { *(.note.GNU-stack) } +}