https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99217

--- Comment #5 from huangpei at loongson dot cn <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=3  -mips16 -mabi=32  
-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=xx
        .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= 0, regs= 1/0, args= 0, gp= 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 

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 <f>:
   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, with b.c,

ambrosehua@3A1000-800M:~$ cat b.c
void f(float a, float b) 
{
}

it is much more complicated.

ambrosehua@3A1000-800M:~$ gcc -fpatchable-function-entry=3  -mips16 -mabi=32  
-c b.c -S  -o b.1.s
ambrosehua@3A1000-800M:~$ cat b.1.s 

        .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=xx
        .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 = f
        .text
        .frame  $17,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 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, without -fpatchable-function-entry=3

ambrosehua@3A1000-800M:~$ gcc  -mips16 -mabi=32   -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=xx
        .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 = f
        .text
        .frame  $17,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 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=32 -c b.c -S -o b.3.s 
-mips16  
depaulose@3A1000-800M:/home/ambrosehua$ cat b.3.s 
        .file   1 "b.c"
        .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=xx
        .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 = f
        .text
        .set    mips16
        .set    nomicromips
        .ent    f
        .type   f, @function
f:
        .frame  $17,8,$31               # vars= 0, regs= 1/0, args= 0, gp= 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 floating
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?

Reply via email to