This is the mail archive of the libc-help@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]

can't find source code of nanosleep.


Hallo Group Members.

Sorry for stupid question, but I really can't find it.
I tried to find it in fedora core 6 debug info RPM and well as in source rpm but also no luck. Then I just got and compiled glibc 2.7. There is nanosleep definition: 

readelf -s --use-dynamic /usr/src/glibc-user/lib/libc-2.7.so | grep nanosleep
  369 558: 0008c110   118    FUNC   WEAK DEFAULT  11 nanosleep
  629 740: 0008c110   118    FUNC   WEAK DEFAULT  11 __nanosleep

the assembly code is the following:
0008c110 <__nanosleep>:
   8c110:	65 83 3d 0c 00 00 00 	cmpl   $0x0,%gs:0xc
   8c117:	00 
   8c118:	75 20                	jne    8c13a <__nanosleep_nocancel+0x20>

0008c11a <__nanosleep_nocancel>:
   8c11a:	89 da                	mov    %ebx,%edx
   8c11c:	8b 4c 24 08          	mov    0x8(%esp),%ecx
   8c120:	8b 5c 24 04          	mov    0x4(%esp),%ebx
   8c124:	b8 a2 00 00 00       	mov    $0xa2,%eax
   8c129:	65 ff 15 10 00 00 00 	call   *%gs:0x10
   8c130:	89 d3                	mov    %edx,%ebx
   8c132:	3d 01 f0 ff ff       	cmp    $0xfffff001,%eax
   8c137:	73 30                	jae    8c169 <__nanosleep_nocancel+0x4f>
   8c139:	c3                   	ret    
   8c13a:	e8 81 1a 04 00       	call   cdbc0 <__libc_enable_asynccancel>
   8c13f:	50                   	push   %eax
   8c140:	89 da                	mov    %ebx,%edx
   8c142:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
   8c146:	8b 5c 24 08          	mov    0x8(%esp),%ebx
   8c14a:	b8 a2 00 00 00       	mov    $0xa2,%eax
   8c14f:	65 ff 15 10 00 00 00 	call   *%gs:0x10
   8c156:	89 d3                	mov    %edx,%ebx
   8c158:	87 04 24             	xchg   %eax,(%esp)
   8c15b:	e8 20 1a 04 00       	call   cdb80 <__libc_disable_asynccancel>
   8c160:	58                   	pop    %eax
   8c161:	3d 01 f0 ff ff       	cmp    $0xfffff001,%eax
   8c166:	73 01                	jae    8c169 <__nanosleep_nocancel+0x4f>
   8c168:	c3                   	ret    
   8c169:	e8 81 96 06 00       	call   f57ef <__i686.get_pc_thunk.cx>
   8c16e:	81 c1 86 4e 0a 00    	add    $0xa4e86,%ecx
   8c174:	8b 89 d4 ff ff ff    	mov    0xffffffd4(%ecx),%ecx
   8c17a:	31 d2                	xor    %edx,%edx
   8c17c:	29 c2                	sub    %eax,%edx
   8c17e:	65 89 11             	mov    %edx,%gs:(%ecx)
   8c181:	83 c8 ff             	or     $0xffffffff,%eax
   8c184:	eb e2                	jmp    8c168 <__nanosleep_nocancel+0x4e>
   8c186:	90                   	nop    
   8c187:	90                   	nop    
   8c188:	90                   	nop    
   8c189:	90                   	nop    


and it is far away from what I found in glibc-2.7/posix/nanosleep.c:

/* Pause execution for a number of nanoseconds.  */
int
__libc_nanosleep (const struct timespec *requested_time,
		  struct timespec *remaining)
{
  __set_errno (ENOSYS);
  return -1;
}
stub_warning (nanosleep)

weak_alias (__libc_nanosleep, __nanosleep)
libc_hidden_def (__nanosleep)
weak_alias (__libc_nanosleep, nanosleep)

I also tried to find the binary in *.o files. There are 2 in:
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
     7: 00000000    95 FUNC    GLOBAL DEFAULT    1 __libc_nanosleep
     8: 0000000a    35 FUNC    GLOBAL DEFAULT    1 __nanosleep_nocancel
    13: 00000000    95 FUNC    WEAK   DEFAULT    1 __nanosleep
    14: 00000000    95 FUNC    WEAK   DEFAULT    1 nanosleep
./build-glibc/posix/nanosleep.o

     7: 00000000    95 FUNC    GLOBAL DEFAULT    1 __libc_nanosleep
     8: 0000000a    35 FUNC    GLOBAL DEFAULT    1 __nanosleep_nocancel
    13: 00000000    95 FUNC    WEAK   DEFAULT    1 __nanosleep
    14: 00000000    95 FUNC    WEAK   DEFAULT    1 nanosleep
./build-glibc/nptl/ptw-nanosleep.o

both of them look like these:
00000000 <__libc_nanosleep>:
   0:	65 83 3d 0c 00 00 00 	cmpl   $0x0,%gs:0xc
   7:	00 
   8:	75 23                	jne    2d <__nanosleep_nocancel+0x23>

0000000a <__nanosleep_nocancel>:
   a:	89 da                	mov    %ebx,%edx
   c:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  10:	8b 5c 24 04          	mov    0x4(%esp),%ebx
  14:	b8 a2 00 00 00       	mov    $0xa2,%eax
  19:	ff 15 00 00 00 00    	call   *0x0
  1f:	89 d3                	mov    %edx,%ebx
  21:	3d 01 f0 ff ff       	cmp    $0xfffff001,%eax
  26:	0f 83 fc ff ff ff    	jae    28 <__nanosleep_nocancel+0x1e>
  2c:	c3                   	ret    
  2d:	e8 fc ff ff ff       	call   2e <__nanosleep_nocancel+0x24>
  32:	50                   	push   %eax
  33:	89 da                	mov    %ebx,%edx
  35:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
  39:	8b 5c 24 08          	mov    0x8(%esp),%ebx
  3d:	b8 a2 00 00 00       	mov    $0xa2,%eax
  42:	ff 15 00 00 00 00    	call   *0x0
  48:	89 d3                	mov    %edx,%ebx
  4a:	87 04 24             	xchg   %eax,(%esp)
  4d:	e8 fc ff ff ff       	call   4e <__nanosleep_nocancel+0x44>
  52:	58                   	pop    %eax
  53:	3d 01 f0 ff ff       	cmp    $0xfffff001,%eax
  58:	0f 83 fc ff ff ff    	jae    5a <__nanosleep_nocancel+0x50>
  5e:	c3                   	ret    


so again, although they look ok, they are not like the one from:
glibc-2.7/posix/nanosleep.c

Can You Where do they come from?

Best regards,
Michal


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