From patchwork Sat Jul 31 04:22:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 44543 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BF3F385ED40 for ; Sat, 31 Jul 2021 04:22:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BF3F385ED40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1627705370; bh=rtvaodQ0E20Dj2Ez7jwg1q1sA0FA01mKjx2kEoL9QUY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gJaXszdVzknx8L9peEG969AmQVKdtqgnZaeYuJT3Twy0agf7ch87LgePghKav1dxr Z5GUsurt3z9sBgc5h9GzL9k503TKEfNE6jwt1HFVmf4YqM6aLyd+wLxrQtyq22yCC7 l/gSGV2Fe6cp0l2PMqVQIJU5RaJUXu3hgVZ7yefA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 275673858432 for ; Sat, 31 Jul 2021 04:22:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 275673858432 Received: by mail-pj1-x1030.google.com with SMTP id pj14-20020a17090b4f4eb029017786cf98f9so6609489pjb.2 for ; Fri, 30 Jul 2021 21:22:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=rtvaodQ0E20Dj2Ez7jwg1q1sA0FA01mKjx2kEoL9QUY=; b=sqHBpuJxVJDFCePJsxPFh7e/s2l0QXGRgGp6xe+k8LbEVkHzZftzS1tsXParAiX5oN R5lzpP3RBI7AUtwxp4zLtsFfEtEGliYwEJyqCGOFzr6hXtWV5mdOUTN03Ya7CkE7DQW4 zfdE8/e0m+DlvSgIAzDA3TctOSpbxy/NwNccUd1fo6NNR94y0vVcraRzCGC6fe67LF98 lfjC6XidXf6hc12cvwF3Qs3fP7mM5WevyyFYXx9pd5H6je7nv4RPSor7EM3cJr32N1GT zd5Y0OERCdMl68mzk4V6XlG/xru/Byf/1afWqo4TVHUywerkivscLA1FxAejzWr+h6Zs BYMA== X-Gm-Message-State: AOAM531ex8NBFocB8O4byAFiSlX6XfqQVVuOWTlEcMrPpY3oM1XGG1g0 eXdaGE35cz6XteMNxwf7gjEkr6PsJaI= X-Google-Smtp-Source: ABdhPJzRHSbaBulNX3C3lvO2qDcWAjbQzzT76BkiJ3ugTAAPRy5LNTafHTTVzbM5zWA/JJu5xpJI1Q== X-Received: by 2002:a17:902:9891:b029:12b:b1aa:3c94 with SMTP id s17-20020a1709029891b029012bb1aa3c94mr5177500plp.80.1627705344024; Fri, 30 Jul 2021 21:22:24 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id m6sm3855346pfc.151.2021.07.30.21.22.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 21:22:23 -0700 (PDT) Received: from gnu-tgl-2.localdomain (gnu-tgl-2 [192.168.1.34]) by gnu-cfl-2.localdomain (Postfix) with ESMTPS id 5A35DC0040 for ; Fri, 30 Jul 2021 21:22:22 -0700 (PDT) Received: from gnu-tgl-2.lan (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 2EC063002BB for ; Fri, 30 Jul 2021 21:22:12 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] Place ENTRY_POINT in .text.startup section [BZ #28153] Date: Fri, 30 Jul 2021 21:22:12 -0700 Message-Id: <20210731042212.2376457-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Glibc assumes that ENTRY_POINT is the lowest address for which we need to keep profiling records. Since GCC 4.6, the main function is placed in .text.startup section. Because ENTRY_POINT in gcrt1.o, which is read in by the linker first, is not placed in .text.startup section, linker may place the main function below ENTRY_POINT which leaves the main function out of profiling records. Place ENTRY_POINT in .text.startup section fixes [BZ #28153]. Tested on Linux/x86-64 and Linux/i686 as well as with build-many-glibcs.py. --- gmon/tst-gmon-gprof.sh | 2 ++ gmon/tst-gmon-static-gprof.sh | 2 ++ sysdeps/aarch64/start.S | 2 +- sysdeps/alpha/start.S | 2 +- sysdeps/arc/start.S | 1 + sysdeps/arm/start.S | 2 +- sysdeps/csky/abiv2/start.S | 2 +- sysdeps/hppa/start.S | 2 +- sysdeps/i386/start.S | 1 + sysdeps/ia64/start.S | 1 + sysdeps/m68k/start.S | 2 +- sysdeps/microblaze/start.S | 2 +- sysdeps/mips/start.S | 2 +- sysdeps/nios2/start.S | 2 +- sysdeps/powerpc/powerpc32/start.S | 2 +- sysdeps/powerpc/powerpc64/start.S | 2 +- sysdeps/riscv/start.S | 1 + sysdeps/s390/s390-32/start.S | 2 +- sysdeps/s390/s390-64/start.S | 2 +- sysdeps/sh/start.S | 2 +- sysdeps/sparc/sparc32/start.S | 2 +- sysdeps/sparc/sparc64/start.S | 2 +- sysdeps/x86_64/start.S | 1 + 23 files changed, 25 insertions(+), 16 deletions(-) diff --git a/gmon/tst-gmon-gprof.sh b/gmon/tst-gmon-gprof.sh index 9d371582b9..dc0be02110 100644 --- a/gmon/tst-gmon-gprof.sh +++ b/gmon/tst-gmon-gprof.sh @@ -39,12 +39,14 @@ trap cleanup 0 cat > "$expected" < "$expected_dot" < "$expected" < "$expected_dot" < - .text + .section .text.startup,"ax",%progbits .align 3 .globl _start .ent _start, 0 diff --git a/sysdeps/arc/start.S b/sysdeps/arc/start.S index 5302a57cab..33403535d4 100644 --- a/sysdeps/arc/start.S +++ b/sysdeps/arc/start.S @@ -33,6 +33,7 @@ env[0...N] environment variables (pointers) NULL. */ + .section .text.startup,"ax",%progbits ENTRY (ENTRY_POINT) /* Needed to make gdb backtraces stop here. */ diff --git a/sysdeps/arm/start.S b/sysdeps/arm/start.S index 9b56bc0cca..756046dd9a 100644 --- a/sysdeps/arm/start.S +++ b/sysdeps/arm/start.S @@ -69,7 +69,7 @@ .syntax unified #endif - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,#function _start: diff --git a/sysdeps/csky/abiv2/start.S b/sysdeps/csky/abiv2/start.S index a565cfa87b..f2b0e74eb6 100644 --- a/sysdeps/csky/abiv2/start.S +++ b/sysdeps/csky/abiv2/start.S @@ -41,7 +41,7 @@ #include - .text + .section .text.startup,"ax",%progbits .globl _start; .type _start,@function; .align 4; diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S index 4a1877f8e8..86a21082e8 100644 --- a/sysdeps/hppa/start.S +++ b/sysdeps/hppa/start.S @@ -51,7 +51,7 @@ .Lp__libc_start_main: .word P%__libc_start_main - .text + .section .text.startup,"ax",%progbits .align 4 .globl _start .export _start, ENTRY diff --git a/sysdeps/i386/start.S b/sysdeps/i386/start.S index 5296b27e65..16767de443 100644 --- a/sysdeps/i386/start.S +++ b/sysdeps/i386/start.S @@ -54,6 +54,7 @@ #include + .section .text.startup,"ax",%progbits ENTRY (_start) /* Clearing frame pointer is insufficient, use CFI. */ cfi_undefined (eip) diff --git a/sysdeps/ia64/start.S b/sysdeps/ia64/start.S index b28f8cb429..e2b11f42d6 100644 --- a/sysdeps/ia64/start.S +++ b/sysdeps/ia64/start.S @@ -48,6 +48,7 @@ * out6: stack_end */ + .section .text.startup,"ax",%progbits .align 32 .global _start diff --git a/sysdeps/m68k/start.S b/sysdeps/m68k/start.S index 98da4db9f3..b2a7f171a5 100644 --- a/sysdeps/m68k/start.S +++ b/sysdeps/m68k/start.S @@ -54,7 +54,7 @@ #include - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,@function _start: diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S index 6589bd4dc7..66c8d8a18d 100644 --- a/sysdeps/microblaze/start.S +++ b/sysdeps/microblaze/start.S @@ -33,7 +33,7 @@ License along with the GNU C Library. If not, see . */ - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,@function _start: diff --git a/sysdeps/mips/start.S b/sysdeps/mips/start.S index 4ec42a2a7f..de0e95a9b8 100644 --- a/sysdeps/mips/start.S +++ b/sysdeps/mips/start.S @@ -71,7 +71,7 @@ void (*rtld_fini) (void), void *stack_end) */ - .text + .section .text.startup,"ax",%progbits .globl ENTRY_POINT .type ENTRY_POINT,@function #ifndef __mips16 diff --git a/sysdeps/nios2/start.S b/sysdeps/nios2/start.S index 7c9696977f..bb03937d6e 100644 --- a/sysdeps/nios2/start.S +++ b/sysdeps/nios2/start.S @@ -65,7 +65,7 @@ value, terminated by an AT_NULL tag. */ - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,%function _start: diff --git a/sysdeps/powerpc/powerpc32/start.S b/sysdeps/powerpc/powerpc32/start.S index 39ce1a18ff..5671d5d7a8 100644 --- a/sysdeps/powerpc/powerpc32/start.S +++ b/sysdeps/powerpc/powerpc32/start.S @@ -56,7 +56,7 @@ L(start_addresses): .long 0 /* Used to be fini. */ ASM_SIZE_DIRECTIVE(L(start_addresses)) - .section ".text" + .section .text.startup,"ax",%progbits ENTRY(_start) /* Save the stack pointer, in case we're statically linked under Linux. */ mr r9,r1 diff --git a/sysdeps/powerpc/powerpc64/start.S b/sysdeps/powerpc/powerpc64/start.S index 71c0c67926..e9b6a434f3 100644 --- a/sysdeps/powerpc/powerpc64/start.S +++ b/sysdeps/powerpc/powerpc64/start.S @@ -61,7 +61,7 @@ L(start_addresses): .section ".toc","aw" .L01: .tc L(start_addresses)[TC],L(start_addresses) - .section ".text" + .section .text.startup,"ax",%progbits ENTRY (_start) /* Save the stack pointer, in case we're statically linked under Linux. */ mr r9,r1 diff --git a/sysdeps/riscv/start.S b/sysdeps/riscv/start.S index 806f6aacd6..8bbf77d9dd 100644 --- a/sysdeps/riscv/start.S +++ b/sysdeps/riscv/start.S @@ -42,6 +42,7 @@ a0 contains the address of a function to be passed to atexit. __libc_start_main wants this in a5. */ + .section .text.startup,"ax",%progbits ENTRY (ENTRY_POINT) /* Terminate call stack by noting ra is undefined. Use a dummy .cfi_label to force starting the FDE. */ diff --git a/sysdeps/s390/s390-32/start.S b/sysdeps/s390/s390-32/start.S index b6cfa4caf3..a418b7f1c6 100644 --- a/sysdeps/s390/s390-32/start.S +++ b/sysdeps/s390/s390-32/start.S @@ -55,7 +55,7 @@ NULL */ - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,@function _start: diff --git a/sysdeps/s390/s390-64/start.S b/sysdeps/s390/s390-64/start.S index 4e6526308a..2bc7f89e6a 100644 --- a/sysdeps/s390/s390-64/start.S +++ b/sysdeps/s390/s390-64/start.S @@ -55,7 +55,7 @@ NULL */ - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,@function _start: diff --git a/sysdeps/sh/start.S b/sysdeps/sh/start.S index 606ee59222..4beaf43f81 100644 --- a/sysdeps/sh/start.S +++ b/sysdeps/sh/start.S @@ -57,7 +57,7 @@ NULL */ - .text + .section .text.startup,"ax",%progbits .globl _start .type _start,@function _start: diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S index 00bf898fb9..073596d815 100644 --- a/sysdeps/sparc/sparc32/start.S +++ b/sysdeps/sparc/sparc32/start.S @@ -37,7 +37,7 @@ #include - .section ".text" + .section .text.startup,"ax",%progbits .align 4 .global _start .type _start,#function diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S index 8520717eba..ad65517ef8 100644 --- a/sysdeps/sparc/sparc64/start.S +++ b/sysdeps/sparc/sparc64/start.S @@ -37,7 +37,7 @@ #include - .section ".text" + .section .text.startup,"ax",%progbits .align 4 .global _start .type _start,#function diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S index 1b3e36826b..ff5d1d2af4 100644 --- a/sysdeps/x86_64/start.S +++ b/sysdeps/x86_64/start.S @@ -55,6 +55,7 @@ #include + .section .text.startup,"ax",%progbits ENTRY (_start) /* Clearing frame pointer is insufficient, use CFI. */ cfi_undefined (rip)