public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luofengwc at qq dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/31302] New: glibc issue about reloc-type R_X86_64_TPOFF64 when llvm build golang project with cgo,
Date: Sun, 28 Jan 2024 00:45:35 +0000	[thread overview]
Message-ID: <bug-31302-131@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2024-01-28  0:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-28  0:45 luofengwc at qq dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31302-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).