From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1962) id 82F7E3858D32; Thu, 30 Nov 2023 12:32:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82F7E3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1701347546; bh=QoxgomD+lceeI6ok9rBxyBX2ewHCskQG3rzPcuLHWW8=; h=From:To:Subject:Date:From; b=npjFsD707v2dUGWyFGUvGG7eZQ+p30gqUaTEQfHLRffop/KR3JeWPz//N4omOPgl/ sSaWgTTJW4sNAvrqWPrvIRsup01Su/nB6vdgNrr9QmqMZj8pUZkuLr7ZG7+ZJHkG5y EHGZ6nEs8jiKjH8fY3fZbEPajhAW1bf7bKnh3B8I= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Stefan Liebler To: glibc-cvs@sourceware.org Subject: [glibc] Avoid padding in _init and _fini. [BZ #31042] X-Act-Checkin: glibc X-Git-Author: Stefan Liebler X-Git-Refname: refs/heads/master X-Git-Oldrev: 7b12776584c51dbecb1033e107f6b9f45de47a1b X-Git-Newrev: 807849965bbdeaa9b0a8f675d098efc520eeaaa8 Message-Id: <20231130123226.82F7E3858D32@sourceware.org> Date: Thu, 30 Nov 2023 12:32:26 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=807849965bbdeaa9b0a8f675d098efc520eeaaa8 commit 807849965bbdeaa9b0a8f675d098efc520eeaaa8 Author: Stefan Liebler Date: Tue Nov 21 13:33:03 2023 +0100 Avoid padding in _init and _fini. [BZ #31042] The linker just concatenates the .init and .fini sections which results in the complete _init and _fini functions. If needed the linker adds padding bytes due to an alignment. GNU ld is adding NOPs, which is fine. But e.g. mold is adding traps which results in broken _init and _fini functions. Thus this patch removes the alignment in .init and .fini sections in crtn.S files. We keep the 4 byte function alignment in crti.S files. As the assembler now also outputs the start of _init and _fini functions as multiples of 4 byte, it perhaps has to fill it. Although GNU as is using NOPs here, to be sure, we just keep the alignment with 0x07 (=NOPs) at the end of crti.S. In order to avoid an obvious NOP slide in _fini, this patch also uses an lg instead of lgr instruction. Then the emitted instructions needs a multiple of 4 bytes. Diff: --- sysdeps/s390/s390-64/crti.S | 2 +- sysdeps/s390/s390-64/crtn.S | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sysdeps/s390/s390-64/crti.S b/sysdeps/s390/s390-64/crti.S index 11ab75e8d9..4c8246da26 100644 --- a/sysdeps/s390/s390-64/crti.S +++ b/sysdeps/s390/s390-64/crti.S @@ -85,7 +85,7 @@ _init: .type _fini,@function _fini: stmg %r6,%r15,48(%r15) - lgr %r1,%r15 + lg %r1,120(%r15) aghi %r15,-160 stg %r1,0(%r15) larl %r12,_GLOBAL_OFFSET_TABLE_ diff --git a/sysdeps/s390/s390-64/crtn.S b/sysdeps/s390/s390-64/crtn.S index 0eabcb346c..6bb1bc9dcf 100644 --- a/sysdeps/s390/s390-64/crtn.S +++ b/sysdeps/s390/s390-64/crtn.S @@ -37,13 +37,11 @@ corresponding to the prologues in crti.S. */ .section .init - .align 4 lg %r4,272(%r15) lmg %r6,%r15,208(%r15) br %r4 .section .fini - .align 4 lg %r4,272(%r15) lmg %r6,%r15,208(%r15) br %r4