From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 02BDA3853D4C; Mon, 21 Nov 2022 06:21:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02BDA3853D4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669011704; bh=Azba+iSwGlszuF/9aEXOS5TxUYmJnBYb4kpSdSM+IOE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=nC7J9BYXTXsJkUoa2ISvmMpHoDxnnFQ3Wafqir+7FN57p2G7o05tpXTZm2YhKpRZc R+i9PMwTHaccljc0MlXXhcRv1FqvRP7wld0MVmT8Odbi4Qmznd4ZxLtKK2/BRoGWmJ 2zSXnnHKKh61S3HMbOUboOqp1BqgYdocl3HbT0tg= From: "i at maskray dot me" To: glibc-bugs@sourceware.org Subject: [Bug libc/29662] s390 glibc wrongly assumes GOT[0] is _DYNAMIC Date: Mon, 21 Nov 2022 06:21:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: i at maskray dot me X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: NOTABUG X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29662 Fangrui Song changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |i at maskray dot me --- Comment #3 from Fangrui Song --- (In reply to Andreas Krebbel from comment #1) > Actually our ABI document defines that the first GOT entry has to point at > _DYNAMIC: >=20 > The format and interpretation of the Global Offset Table is processor > specific. For s390x the symbol _GLOBAL_OFFSET_TABLE_ may be used to access > the table. The symbol refers to the start of the .got section. Two words = in > the GOT are reserved: >=20 > =E2=80=A2 The word at _GLOBAL_OFFSET_TABLE_[0] is set by the linkage edit= or to hold > the address of the dynamic structure, referenced with the symbol _DYNAMIC. > This allows a program, such as the dynamic linker, to find its own dynam= ic > structure without having yet processed its relocation entries. This is > especially important for the dynamic linker, because it must initialize > itself without relying on other programs to relocate its memory image. > =E2=80=A2 The word at _GLOBAL_OFFSET_TABLE_[1] is reserved for future use. >=20 > Please see: > https://github.com/IBM/s390x-abi/releases/download/v1.6/lzsabi_s390x.pdf This is the legacy SunOS 4.x ld.so way of getting `__DYNAMIC`, which was co= pied by NetBSD ldso in 1993, and glibc. `_GLOBAL_OFFSET_TABLE_[0] =3D _DYNAMIC` is not really necessary for ldso to= get _DYNAMIC. It can use plain C with a hidden visibility of _DYNAMIC. Even on x86-32 with no PC-relative relocations, I managed to change the gli= bc port to avoid `_GLOBAL_OFFSET_TABLE_[0] =3D _DYNAMIC` assumption (commit 91e92272caefad4b6156572fc41671dcbd93afe5) /* Return the link-time address of _DYNAMIC. */ static inline Elf32_Addr __attribute__ ((unused)) elf_machine_dynamic (void) { extern Elf32_Dyn _DYNAMIC[] attribute_hidden; return (Elf32_Addr) _DYNAMIC - elf_machine_load_address (); } It would be nice to drop the assumption for s390x as well. It's very odd to define `_GLOBAL_OFFSET_TABLE_[0] =3D _DYNAMIC` in a psABI, at least I haven= 't seen it in other psABI documents. --=20 You are receiving this mail because: You are on the CC list for the bug.=