From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6BF933858D33; Tue, 23 Feb 2021 11:37:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BF933858D33 From: "huangpei at loongson dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99217] New: [MIPS] wrong function entry with -fpatchable-function-entry Date: Tue, 23 Feb 2021 11:37:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: huangpei at loongson dot cn X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Tue, 23 Feb 2021 11:37:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99217 Bug ID: 99217 Summary: [MIPS] wrong function entry with -fpatchable-function-entry Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: huangpei at loongson dot cn Target Milestone: --- On Debian AMD64 unstable, ----------------- depaulose@localhost:~$ cat a.c void f() {} depaulose@localhost:~$ gcc -fpatchable-function-entry=3D3 -c a.c depaulose@localhost:~$ objdump -d a.o a.o: file format elf64-tradlittlemips Disassembly of section .text: 0000000000000000 : ... 000000000000000c : c: 67bdfff0 daddiu sp,sp,-16 10: ffbe0008 sd s8,8(sp) 14: 03a0f025 move s8,sp 18: 00000000 nop 1c: 03c0e825 move sp,s8 20: dfbe0008 ld s8,8(sp) 24: 67bd0010 daddiu sp,sp,16 28: 03e00008 jr ra 2c: 00000000 nop depaulose@localhost:~$ readelf -s a.o Symbol table '.symtab' contains 14 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS a.c 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 3: 0000000000000000 0 SECTION LOCAL DEFAULT 2 4: 0000000000000000 0 SECTION LOCAL DEFAULT 3 5: 0000000000000000 0 SECTION LOCAL DEFAULT 8 6: 0000000000000000 0 SECTION LOCAL DEFAULT 9 7: 0000000000000000 0 SECTION LOCAL DEFAULT 12 8: 0000000000000000 0 SECTION LOCAL DEFAULT 4 9: 0000000000000000 0 SECTION LOCAL DEFAULT 5 10: 0000000000000000 0 SECTION LOCAL DEFAULT 6 11: 0000000000000000 0 SECTION LOCAL DEFAULT 11 12: 0000000000000000 0 SECTION LOCAL DEFAULT 13 13: 000000000000000c 36 FUNC GLOBAL DEFAULT 1 f depaulose@localhost:~$ gcc --version gcc (Debian 10.2.1-6) 10.2.1 20210110 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. depaulose@localhost:~$ as --version GNU assembler (GNU Binutils for Debian) 2.35.2 Copyright (C) 2020 Free Software Foundation, Inc. This assembler was configured for a target of `mips64el-linux-gnuabi64'. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or later. This program has absolutely no warranty. This assembler was configured for a target of `mips64el-linux-gnuabi64'. ------------------ It turned out that function address is wrong. It is expected that the funct= ion entry is 0 not 0xc On Debian 10 , for arm64, same file -------------------------- ambrosehua@ambrosehua-HP-xw6600-Workstation:Downloads$ aarch64-linux-gnu-gc= c-8 -fpatchable-function-entry=3D3 -c a.c ambrosehua@ambrosehua-HP-xw6600-Workstation:Downloads$ aarch64-linux-gnu-objdump -d a.o a.o: file format elf64-littleaarch64 Disassembly of section .text: 0000000000000000 : 0: d503201f nop 4: d503201f nop 8: d503201f nop c: d503201f nop 10: d65f03c0 ret ambrosehua@ambrosehua-HP-xw6600-Workstation:Downloads$ readelf -s a.o Symbol table '.symtab' contains 12 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS a.c 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 3: 0000000000000000 0 SECTION LOCAL DEFAULT 2 4: 0000000000000000 0 SECTION LOCAL DEFAULT 3 5: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 $x 6: 0000000000000000 0 SECTION LOCAL DEFAULT 4 7: 0000000000000000 0 SECTION LOCAL DEFAULT 7 8: 0000000000000014 0 NOTYPE LOCAL DEFAULT 8 $d 9: 0000000000000000 0 SECTION LOCAL DEFAULT 8 10: 0000000000000000 0 SECTION LOCAL DEFAULT 6 11: 0000000000000000 20 FUNC GLOBAL DEFAULT 1 f ---------------------- here function address of f is right=