This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64


The below is analysis for this patch. All the test is done on mips64

==================================
#This program works well

main()
{
  statfs("/tmp", sfbuf);
}
==================================
#This program does not work

main()
{
  statfs64("/tmp", sfbuf);
}
==================================
#This program does not work if we define _FILE_OFFSET_BITS=64
#since statfs would be linked to statfs64 on this condition

#define _FILE_OFFSET_BITS=64
#include <*.h>
main()
{
  statfs("/tmp", sfbuf);
}
==================================
#The below is elf information

-bash-3.2$ readelf -h ./mabi_64/libc.so
ELF Header:
Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, big endian
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: MIPS R3000
Flags: 0x60000007, noreorder, pic, cpic, mips64
....



-bash-3.2$ readelf -s ./mabi_64/libc.so |grep statfs 6746: 00000000000ee39c 28 FUNC GLOBAL DEFAULT 11 __statfs 6806: 00000000000ee400 8 FUNC WEAK DEFAULT 11 statfs64 6821: 00000000000ee39c 28 FUNC WEAK DEFAULT 11 statfs


-bash-3.2$ objdump -dS ./mabi_64/libc.so


00000000000ee39c <__statfs>:
   ee39c:       2402140e        li      v0,5134
   ee3a0:       0000000c        syscall
   ee3a4:       14e0fff6        bnez    a3,ee380 <__fxstatat64+0xb0>
   ee3a8:       00000000        nop
   ee3ac:       03e00008        jr      ra
   ee3b0:       00000000        nop
        ...
   ee3c0:       0380082d        move    at,gp
   ee3c4:       3c1c000a        lui     gp,0xa
   ee3c8:       279c6b14        addiu   gp,gp,27412
   ee3cc:       0399e02d        daddu   gp,gp,t9
   ee3d0:       df998588        ld      t9,-31352(gp)
   ee3d4:       03200008        jr      t9
   ee3d8:       0020e02d        move    gp,at

00000000000ee400 <statfs64>:
   ee400:       03e00008        jr      ra
   ee404:       00000000        nop
        ...

=========================================================
The statfs64 in libc does not any work and is dummy function
since the linux kernel does not implement the statfs64 syscall
when define _MIPS_SIM_ABI64,

the reason why statfs64 syscall is not implemented is that statfs
has equal function to statfs64 on mips64, I think.

=========================================================

On x86-64, statfs64 in libc has its true implementation since
the statfs64 syscall exists in kernel.

But statfs64 is weak-aliased to statfs at last, not call the true
statfs64 syscall on x86_64.

The below information comes from common_pc_64.

readelf -s libc-2.11.1.so |grep statfs
1241: 00000000000c2350 37 FUNC GLOBAL DEFAULT 11 __statfs@@GLIBC_2.2.5
1564: 00000000000c2350 37 FUNC WEAK DEFAULT 11 statfs@@GLIBC_2.2.5
1761: 00000000000c2350 37 FUNC WEAK DEFAULT 11 statfs64@@GLIBC_2.2.5


====================================================
So I think the mips64 should have the same result.

====================================================


On 08/19/2011 05:50 PM, rongqing.li@windriver.com wrote:
From: Roy.Li<rongqing.li@windriver.com>

statfs64 is null function since __NR_statfs64 is not defined when gcc
uses _MIPS_SIM_ABI64.

When macro _FILE_OFFSET_BITS=64, statfs function becomes statfs64,
the result is these two functions can not work.

Signed-off-by: Roy.Li<rongqing.li@windriver.com>
---
  .../unix/sysv/linux/mips/mips64/n64/syscalls.list  |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index 8d70e45..a93943d 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -5,3 +5,4 @@ sync_file_range	-	sync_file_range	Ci:iiii	sync_file_range
  prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64

  fanotify_mark	EXTRA	fanotify_mark	i:iiiis	fanotify_mark
+statfs          -       statfs          i:sp    __statfs        statfs statfs64



-- Best Reagrds, Roy | RongQing Li


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]