Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Nadav Har'El
On Wed, Aug 31, 2016 at 5:33 PM, Nadav Har'El wrote: > I'm more worried about the symbol(sym) part of this code... What if there > is no symbol involved? In this case (again see readelf --relocs for your > object), there is no object... > > I think the code involved is the

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Nadav Har'El
On Wed, Aug 31, 2016 at 5:13 PM, Benoît Canet wrote: >case R_X86_64_TPOFF64: >// FIXME: assumes TLS segment comes before DYNAMIC segment > I'm not sure this code even runs when loading a shared object. I think it only runs when loading the kernel, and

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Benoît Canet
case R_X86_64_TPOFF64: // FIXME: assumes TLS segment comes before DYNAMIC segment This is not the case: See in the dump: 000c8d90 : c8d90: 48 8b 0d 29 72 38 00mov0x387229(%rip),%rcx# 44ffc0 <_DYNAMIC+0x200> c8d97: 64 48 8b 09 mov

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Benoît Canet
This is what I saw in the code managing the flags. By anyway I think you are right and shared is an "impasse". On Wed, Aug 31, 2016 at 4:06 PM, Nadav Har'El wrote: > > On Wed, Aug 31, 2016 at 4:26 PM, Benoît Canet > wrote: > >> >> Buildmode

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Nadav Har'El
On Wed, Aug 31, 2016 at 4:26 PM, Benoît Canet wrote: > > Buildmode shared alone crash. > > > the flags are |= between them. > This is not what I see in https://golang.org/src/cmd/go/build.go But it seems these two options indeed have a funny interaction between

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Nadav Har'El
On Wed, Aug 31, 2016 at 4:26 PM, Benoît Canet wrote: > > > Go use it's own tls see: http://blog.altoros.com/golang-internals-part-5- > runtime-bootstrap-process.html > Thanks. Interesting. It is very sad, and surprising, that Go does this: If I understand

Re: [PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Benoît Canet
Buildmode shared alone crash. the flags are |= between them. Go use it's own tls see: http://blog.altoros.com/golang-internals-part-5-runtime-bootstrap-process.html On Wed, Aug 31, 2016 at 3:22 PM, Nadav Har'El wrote: > > On Wed, Aug 31, 2016 at 4:05 PM, Benoit Canet

[PATCH] golang-example: Use shared and pie compilation flags

2016-08-31 Thread Benoit Canet
The c-shared is intented to build C libraries hence it does not export main and it's initialization does not set the fs register with arch_prctl() leading to a crash. Use -buildmode=shared -buildmode=pie to produce a library which export main and is position independant while having and init