public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64
@ 2011-08-19  9:51 rongqing.li
  2011-08-20  1:06 ` Rongqing Li
  2011-09-06 14:08 ` Joseph S. Myers
  0 siblings, 2 replies; 4+ messages in thread
From: rongqing.li @ 2011-08-19  9:51 UTC (permalink / raw)
  To: libc-ports

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
-- 
1.7.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64
  2011-08-19  9:51 [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64 rongqing.li
@ 2011-08-20  1:06 ` Rongqing Li
  2011-08-24  9:29   ` Rongqing Li
  2011-09-06 14:08 ` Joseph S. Myers
  1 sibling, 1 reply; 4+ messages in thread
From: Rongqing Li @ 2011-08-20  1:06 UTC (permalink / raw)
  To: libc-ports

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64
  2011-08-20  1:06 ` Rongqing Li
@ 2011-08-24  9:29   ` Rongqing Li
  0 siblings, 0 replies; 4+ messages in thread
From: Rongqing Li @ 2011-08-24  9:29 UTC (permalink / raw)
  To: libc-ports

Could anyone give any comments about this fix?
Thanks

-Roy

On 08/20/2011 09:06 AM, Rongqing Li wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64
  2011-08-19  9:51 [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64 rongqing.li
  2011-08-20  1:06 ` Rongqing Li
@ 2011-09-06 14:08 ` Joseph S. Myers
  1 sibling, 0 replies; 4+ messages in thread
From: Joseph S. Myers @ 2011-09-06 14:08 UTC (permalink / raw)
  To: rongqing.li; +Cc: libc-ports

On Fri, 19 Aug 2011, rongqing.li@windriver.com wrote:

> 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

I don't think this is the complete fix.  You're not defining an __statfs64 
alias so statvfs64 will continue to use the old, bad __statfs64, and 
you're not fixing fstatfs64 or doing anything to stop the old statfs64 and 
fstatfs64 being built.

This is the patch I've applied which fixes those issues.  It should be 
possible to make statvfs64 and fstatvfs64 into aliases of statvfs and 
fstatvfs (since they don't use struct stat64 - different from struct stat 
on MIPS n64 - in their interfaces) but I haven't tried that and the 
existing implementations of those functions should work anyway.

diff --git a/ChangeLog.mips b/ChangeLog.mips
index b2998b8..75f87fe 100644
--- a/ChangeLog.mips
+++ b/ChangeLog.mips
@@ -1,3 +1,11 @@
+2011-09-06  Joseph Myers  <joseph@codesourcery.com>
+
+	[BZ #13109]
+	* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list (fstatfs)
+	(statfs): New.
+	* sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c,
+	sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c: New.
+
 2011-08-02  Matt Turner  <mattst88@gmail.com>
 
 	* sysdeps/mips/bits/atomic.h: Workaround R10K ll/sc errata.
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
new file mode 100644
index 0000000..6e25b02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/fstatfs64.c
@@ -0,0 +1 @@
+/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
new file mode 100644
index 0000000..6e25b02
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/statfs64.c
@@ -0,0 +1 @@
+/* Empty.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index 8d70e45..c94fe75 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -5,3 +5,6 @@ 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
+
+fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
+statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-06 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-19  9:51 [PATCH 1/1] statfs64 should be weak-aliased to statfs on mips64/n64 as on X86-64 rongqing.li
2011-08-20  1:06 ` Rongqing Li
2011-08-24  9:29   ` Rongqing Li
2011-09-06 14:08 ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).