From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A61043858C52; Wed, 20 Jul 2022 10:44:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A61043858C52 From: "sen2403 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/91299] LTO inlines a weak definition in presence of a non-weak definition from an ELF file Date: Wed, 20 Jul 2022 10:44:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 8.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sen2403 at hotmail dot com X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2022 10:44:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D91299 --- Comment #10 from Eason Lai --- Add my test program. $cat boo.c #include "boo.h" int get_t(void) { return 1; } $cat main.c #include "boo.h" __attribute__((weak)) int get_t(void) { return 0; } int a; int main(void) { a =3D get_t(); return a; } $arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=3Dcortex-m33 -Os -flto -c = main.c -o main.o #arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=3Dcortex-m33 -Os -fno-lto = -c boo.c -o boo.o #arm-none-eabi-gcc --specs=3Dnano.specs -lnosys -nostartfiles -Wl,--gc-sect= ions=20 -Wl,-Ttest.ld boo.o main.o -o main -save-temps $arm-none-eabi-objdump -d main main: file format elf32-littlearm Disassembly of section .test: 00001000
: 1000: 2000 movs r0, #0 1002: 4770 bx lr $cat "./-lm.res" 1 main.o 3 190 a62a5458565feecb PREEMPTED_REG get_t 192 a62a5458565feecb PREVAILING_DEF main 196 a62a5458565feecb PREVAILING_DEF_IRONLY a=