From e6ca125f14d0f677205d3247f26da60ab8069b9c Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Fri, 21 Dec 2012 01:27:50 +1100 Subject: [PATCH] cmd/[568]l: do not generate PT_TLS on openbsd The OpenBSD ld.so(1) does not currently support PT_TLS and refuses to load ELF binaries that contain PT_TLS sections. Do not emit PT_TLS sections - we will handle this appropriately in runtime/cgo instead. R=golang-dev, minux.ma, iant CC=golang-dev https://golang.org/cl/6846064 --- src/cmd/5l/asm.c | 5 ++++- src/cmd/6l/asm.c | 5 ++++- src/cmd/8l/asm.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c index a937650480..f62c927e24 100644 --- a/src/cmd/5l/asm.c +++ b/src/cmd/5l/asm.c @@ -1015,7 +1015,10 @@ asmb(void) phsh(ph, sh); // .tbss (optional) and TLS phdr - if(tlsoffset != 0) { + // Do not emit PT_TLS for OpenBSD since ld.so(1) does + // not currently support it. This is handled + // appropriately in runtime/cgo. + if(tlsoffset != 0 && HEADTYPE != Hopenbsd) { ph = newElfPhdr(); ph->type = PT_TLS; ph->flags = PF_R; diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c index 89ea86109f..b0ff15423a 100644 --- a/src/cmd/6l/asm.c +++ b/src/cmd/6l/asm.c @@ -1116,7 +1116,10 @@ asmb(void) /* * Thread-local storage segment (really just size). */ - if(tlsoffset != 0) { + // Do not emit PT_TLS for OpenBSD since ld.so(1) does + // not currently support it. This is handled + // appropriately in runtime/cgo. + if(tlsoffset != 0 && HEADTYPE != Hopenbsd) { ph = newElfPhdr(); ph->type = PT_TLS; ph->flags = PF_R; diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c index 3d3248f937..e83e4a8792 100644 --- a/src/cmd/8l/asm.c +++ b/src/cmd/8l/asm.c @@ -1179,7 +1179,10 @@ asmb(void) /* * Thread-local storage segment (really just size). */ - if(tlsoffset != 0) { + // Do not emit PT_TLS for OpenBSD since ld.so(1) does + // not currently support it. This is handled + // appropriately in runtime/cgo. + if(tlsoffset != 0 && HEADTYPE != Hopenbsd) { ph = newElfPhdr(); ph->type = PT_TLS; ph->flags = PF_R; -- 2.48.1