From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C03E43858D28; Sat, 4 Dec 2021 07:54:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C03E43858D28 From: "huangpei at loongson dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99217] [MIPS] wrong function entry with -fpatchable-function-entry Date: Sat, 04 Dec 2021 07:54:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: huangpei at loongson dot cn X-Bugzilla-Status: NEW 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: Sat, 04 Dec 2021 07:54:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99217 --- Comment #5 from huangpei at loongson dot cn --- Hi, with this fix and bug 93242 fixed, a.c with mips16 is OK, ambrosehua@3A1000-800M:~$ gcc -fpatchable-function-entry=3D3 -mips16 -mabi= =3D32=20=20 -c a.c -S -o a.1.s ambrosehua@3A1000-800M:~$ cat a.1.s .file 1 "a.c" .section .mdebug.abi32 .previous .nan legacy .module fp=3Dxx .module nooddspreg .abicalls .text .align 2 .globl f .set mips16 .set nomicromips .ent f .type f, @function f: .section __patchable_function_entries,"a",@progbits .4byte $LPFE1 .text $LPFE1: .set noreorder nop .set reorder .set noreorder nop .set reorder .set noreorder nop .set reorder .frame $17,8,$31 # vars=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 0 .mask 0x00020000,-4 .fmask 0x00000000,0 save 8,$17 move $17,$sp .set noreorder nop .set reorder move $sp,$17 restore 8,$17 jr $31 .end f .size f, .-f .ident "GCC: (Debian 8.3.0-8.lnd.4) 8.3.0" ambrosehua@3A1000-800M:~$ objdump -tdr a.1.o=20 a.1.o: file format elf32-tradlittlemips SYMBOL TABLE: 00000000 l df *ABS* 00000000 a.c 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 00000000 l d .mdebug.abi32 00000000 .mdebug.abi32 00000000 l d __patchable_function_entries 00000000 __patchable_function_entries 00000000 l .text 00000000 0xf0 $LPFE1 00000000 l d .reginfo 00000000 .reginfo 00000000 l d .MIPS.abiflags 00000000 .MIPS.abiflags 00000000 l d .pdr 00000000 .pdr 00000000 l d .comment 00000000 .comment 00000000 l d .gnu.attributes 00000000 .gnu.attributes 00000000 g F .text 00000012 f Disassembly of section .text: 00000000 : 0: 6500 nop 2: 6500 nop 4: 6500 nop 6: 6491 save 8,s1 8: 673d move s1,sp a: 6500 nop c: 65b9 move sp,s1 e: 6411 restore 8,s1 10: e8a0 jrc ra 12: 6500 nop 14: 6500 nop 16: 6500 nop 18: 6500 nop 1a: 6500 nop 1c: 6500 nop 1e: 6500 nop but=EF=BC=8C with b.c, ambrosehua@3A1000-800M:~$ cat b.c void f(float a, float b)=20 { } it is much more complicated. ambrosehua@3A1000-800M:~$ gcc -fpatchable-function-entry=3D3 -mips16 -mabi= =3D32=20=20 -c b.c -S -o b.1.s ambrosehua@3A1000-800M:~$ cat b.1.s=20 .section .mdebug.abi32 .previous .nan legacy .module fp=3Dxx .module nooddspreg .abicalls .text .align 2 .globl f .set mips16 .set nomicromips .ent f .type f, @function f: .section __patchable_function_entries,"a",@progbits .4byte $LPFE1 .text $LPFE1: .set noreorder nop .set reorder .set noreorder nop .set reorder .set noreorder nop .set reorder # Stub function for f (float, float) .section .mips16.fn.f,"ax",@progbits .align 2 .set mips16 .set nomicromips .ent __fn_stub_f .type __fn_stub_f, @function __fn_stub_f: .section __patchable_function_entries .4byte $LPFE2 .section .mips16.fn.f $LPFE2: .set noreorder nop .set reorder .set noreorder nop .set reorder .set noreorder nop .set reorder .set nomips16 .set nomicromips .ent __fn_stub_f .type __fn_stub_f, @function __fn_stub_f: .set noreorder .cpload $25 .set reorder .reloc 0,R_MIPS_NONE,f la $25,__fn_local_f mfc1 $4,$f12 mfc1 $5,$f14 jr $25 .end __fn_stub_f __fn_local_f =3D f .text .frame $17,8,$31 # vars=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 0 .mask 0x00020000,-4 .fmask 0x00000000,0 save 8,$17 move $17,$sp sw $4,8($17) sw $5,12($17) .set noreorder nop .set reorder move $sp,$17 restore 8,$17 jr $31 .end f .size f, .-f .ident "GCC: (Debian 8.3.0-8.lnd.4) 8.3.0" for comparison=EF=BC=8C without -fpatchable-function-entry=3D3 ambrosehua@3A1000-800M:~$ gcc -mips16 -mabi=3D32 -c b.c -S -o b.2.s ambrosehua@3A1000-800M:~$ cat b.2.s .file 1 "b.c" .section .mdebug.abi32 .previous .nan legacy .module fp=3Dxx .module nooddspreg .abicalls .text .align 2 .globl f .set mips16 .set nomicromips .ent f .type f, @function f: # Stub function for f (float, float) .section .mips16.fn.f,"ax",@progbits .align 2 .set mips16 .set nomicromips .ent __fn_stub_f .type __fn_stub_f, @function __fn_stub_f: .set nomips16 .set nomicromips .ent __fn_stub_f .type __fn_stub_f, @function __fn_stub_f: .set noreorder .cpload $25 .set reorder .reloc 0,R_MIPS_NONE,f la $25,__fn_local_f mfc1 $4,$f12 mfc1 $5,$f14 jr $25 .end __fn_stub_f __fn_local_f =3D f .text .frame $17,8,$31 # vars=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 0 .mask 0x00020000,-4 .fmask 0x00000000,0 save 8,$17 move $17,$sp sw $4,8($17) sw $5,12($17) .set noreorder nop .set reorder move $sp,$17 restore 8,$17 jr $31 .end f .size f, .-f .ident "GCC: (Debian 8.3.0-8.lnd.4) 8.3.0" with original gcc 8.3 in Debian10, depaulose@3A1000-800M:/home/ambrosehua$ gcc -mabi=3D32 -c b.c -S -o b.3.s=20 -mips16=20=20 depaulose@3A1000-800M:/home/ambrosehua$ cat b.3.s=20 .file 1 "b.c" .section .mdebug.abi32 .previous .nan legacy .module fp=3Dxx .module nooddspreg .abicalls .text .align 2 .globl f # Stub function for f (float, float) .section .mips16.fn.f,"ax",@progbits .align 2 .set nomips16 .set nomicromips .ent __fn_stub_f .type __fn_stub_f, @function __fn_stub_f: .set noreorder .cpload $25 .set reorder .reloc 0,R_MIPS_NONE,f la $25,__fn_local_f mfc1 $4,$f12 mfc1 $5,$f14 jr $25 .end __fn_stub_f __fn_local_f =3D f .text .set mips16 .set nomicromips .ent f .type f, @function f: .frame $17,8,$31 # vars=3D 0, regs=3D 1/0, args=3D 0= , gp=3D 0 .mask 0x00020000,-4 .fmask 0x00000000,0 save 8,$17 move $17,$sp sw $4,8($17) sw $5,12($17) .set noreorder nop .set reorder move $sp,$17 restore 8,$17 jr $31 .end f .size f, .-f .ident "GCC: (Debian 8.3.0-6) 8.3.0" I think there is somthing wrong here with handling stub for O32 MIPS16 floa= ting parameter. +. Point 1, with b.3.s, the func entry should be __fn_stub_f instead of f, which I mean the f in symbol table should point to the __fn_stub_f in the b= .3.s , and __fn_local_f in symbol table should point to the f in the b.3.s ; +. Point 2, if Point 1 is right, the b.2.s should be just like Point 1, but= it is not right now, and we need fix this at first; +. Point 3, if Point 1 is right, b.1.s should has only 3 nops in the mip32= 32 stub code, instead of both in mips32 stub code and mip16 code. Did I get it right?=