public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "i at maskray dot me" <sourceware-bugzilla@sourceware.org>
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 [thread overview]
Message-ID: <bug-29662-131-XTGpjnldKP@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29662-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=29662
Fangrui Song <i at maskray dot me> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |i at maskray dot me
--- Comment #3 from Fangrui Song <i at maskray dot me> ---
(In reply to Andreas Krebbel from comment #1)
> Actually our ABI document defines that the first GOT entry has to point at
> _DYNAMIC:
>
> 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:
>
> • The word at _GLOBAL_OFFSET_TABLE_[0] is set by the linkage editor 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 dynamic
> 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.
> • The word at _GLOBAL_OFFSET_TABLE_[1] is reserved for future use.
>
> 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 copied
by NetBSD ldso in 1993, and glibc.
`_GLOBAL_OFFSET_TABLE_[0] = _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 glibc
port to avoid `_GLOBAL_OFFSET_TABLE_[0] = _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] = _DYNAMIC` in a psABI, at least I haven't
seen it in other psABI documents.
--
You are receiving this mail because:
You are on the CC list for the bug.
next prev parent reply other threads:[~2022-11-21 6:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-08 1:28 [Bug libc/29662] New: " rui314 at gmail dot com
2022-10-12 14:32 ` [Bug libc/29662] " krebbel at linux dot ibm.com
2022-10-13 1:21 ` rui314 at gmail dot com
2022-11-21 6:21 ` i at maskray dot me [this message]
2022-11-21 7:56 ` rui314 at gmail dot com
2022-11-21 9:28 ` 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-29662-131-XTGpjnldKP@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).