This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: Add sysdeps/unix/sysv/linux/x86_64/x32/lseek.S


On Mon, May 21, 2012 at 2:26 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> On Fri, May 18, 2012 at 11:36 AM, Roland McGrath <roland@hack.frob.com> wrote:
>> >> Like x86-64, x32 doesn't provide llseek at all. Just like x86-64,
>> >> x32 llseek.o defines lseek/lseek64:
>> >
>> > Well, it would be cleaner for both if lseek.o defines lseek
>> > and llseek.o is empty.
>>
>> This is controlled by sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>>
>> # Whee! 64-bit systems naturally implement llseek.
>> llseek ? ? ? ? ? ? ? ?EXTRA ? lseek ? ? ? ? ? Ci:iii ?__libc_lseek ? ?__lseek lseek __libc_lseek64
>> __llseek llseek __lseek64 lseek64
>>
>> It is the same fora ll 64-bit archs. ?X32 just followed them.
>
> There it makes some sense because it actually defines the symbol llseek.
> You said x32 was not going to provide llseek at all, which is different
> from x86_64 (which does define llseek).
>

I believe it is a bug on x86-64:

[hjl@gnu-6 tmp]$ cat s.c
extern void llseek (void);

int
main ()
{
  llseek ();
  return 0;
}
[hjl@gnu-6 tmp]$ gcc s.c
[hjl@gnu-6 tmp]$ strace ./a.out
execve("./a.out", ["./a.out"], [/* 55 vars */]) = 0
brk(0)                                  = 0x601000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7ffff7ffd000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=125828, ...}) = 0
mmap(NULL, 125828, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffff7fde000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\24\"\3458\0\0\0"...,
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1945616, ...}) = 0
mmap(0x38e5200000, 3777672, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38e5200000
mprotect(0x38e5390000, 2097152, PROT_NONE) = 0
mmap(0x38e5590000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x190000) = 0x38e5590000
mmap(0x38e5595000, 21640, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x38e5595000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7ffff7fdd000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7ffff7fdb000
arch_prctl(ARCH_SET_FS, 0x7ffff7fdb720) = 0
mprotect(0x38e5590000, 16384, PROT_READ) = 0
mprotect(0x38e501e000, 4096, PROT_READ) = 0
munmap(0x7ffff7fde000, 125828)          = 0
lseek(1, 140737488347448, 0xffffe148 /* SEEK_??? */) = -1 EINVAL
(Invalid argument)
exit_group(0)                           = ?
[hjl@gnu-6 tmp]$

x86-64 provides a llseek which is an alias of lseek.  I don't see how
it can work as llseek:

      int _llseek(unsigned int fd, unsigned long offset_high,
                   unsigned long offset_low, loff_t *result,
                   unsigned int whence);


-- 
H.J.


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