public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/31302] New: glibc issue about reloc-type R_X86_64_TPOFF64 when llvm build golang project with cgo,
@ 2024-01-28  0:45 luofengwc at qq dot com
  2024-01-28  0:48 ` [Bug libc/31302] glibc issue about reloc-type R_X86_64_TPOFF64 when llvm build golang project with cgo luofengwc at qq dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: luofengwc at qq dot com @ 2024-01-28  0:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=31302

            Bug ID: 31302
           Summary: glibc issue about reloc-type R_X86_64_TPOFF64 when
                    llvm build golang project with cgo,
           Product: glibc
           Version: 2.38
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: luofengwc at qq dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

hi i want to report glibc issue when i use llvm, the following is detail:

when clang build golang on x86 arch, and use cgo function, build to static
linked exec, exec will segment fault. 

this is demo.go:

package main
// #cgo LDFLAGS: -ldl
// #include <stdlib.h>
// #include <dlfcn.h>
import "C"
import (
 "fmt"
)
func main() {
 fmt.Printf("This is go demo\n")
 C.CString("libsystemd-login.so.0")
 return
}

build static exec command :
export CC=clang
CGO_ENABLED=1 CGO_CFLAGS="-fstack-protector-strong -fPIE"
CGO_CPPFLAGS="-fstack-protector-strong -fPIE"
CGO_LDFLAGS_ALLOW='-Wl,-z,relro,-z,now' CGO_LDFLAGS="-Wl,-z,relro,-z,now
-Wl,-z,noexecstack" go build -buildmode=pie -o demo -ldflags '-buildid=none
-tmpdir=. -extldflags=-ftrapv -extldflags=-Wl,-z,relro,-z,now
-linkmode=external -extldflags=-static-pie' demo.go

and gdb segment fault stack, indicate crash in glibc

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e835dc in _dl_signal_error ()
(gdb) bt
#0 0x00007ffff7e835dc in _dl_signal_error ()
#1 0x00007ffff7ebf6f3 in _dl_allocate_static_tls ()
#2 0x00007ffff7e843d0 in _dl_relocate_static_pie ()
#3 0x00007ffff7e46b59 in __libc_start_main_impl ()
#4 0x00007ffff7dc4665 in _start ()
when debug, i found clang change the sym relocate type from R_X86_64_GOTTPOFF
to R_X86_64_TPOFF64

readelf -a glibc/dl-error.o | grep R_X86_64_GOTTPOFF
readelf -a demo | grep R_X86_64_TPOFF64
i want to know why glibc does not match this relocation type.

thank you

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-03-15 21:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-28  0:45 [Bug libc/31302] New: glibc issue about reloc-type R_X86_64_TPOFF64 when llvm build golang project with cgo, luofengwc at qq dot com
2024-01-28  0:48 ` [Bug libc/31302] glibc issue about reloc-type R_X86_64_TPOFF64 when llvm build golang project with cgo luofengwc at qq dot com
2024-01-28  0:51 ` luofengwc at qq dot com
2024-01-28  1:23 ` luofengwc at qq dot com
2024-01-28  8:32 ` sam at gentoo dot org
2024-01-28 19:30 ` fweimer at redhat dot com
2024-01-29  1:16 ` luofengwc at qq dot com
2024-01-29  1:23 ` luofengwc at qq dot com
2024-01-29  1:33 ` luofengwc at qq dot com
2024-01-29  1:39 ` luofengwc at qq dot com
2024-01-29  5:50 ` fweimer at redhat dot com
2024-01-29 11:41 ` luofengwc at qq dot com
2024-01-29 11:43 ` fweimer at redhat dot com
2024-01-30  1:05 ` luofengwc at qq dot com
2024-03-15 21:04 ` i at maskray dot me

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).