This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: gdb cannot find "../sysdeps/unix/syscall-template.S"


On 14 Jan 2016 23:23, Jan Kratochvil wrote:
> On Thu, 14 Jan 2016 23:11:02 +0100, Linux Mercedes wrote:
> > As Mike Frysinger points out, that source isn't going to
> > be particularly helpful to look at anyway.
> +
> On Thu, 14 Jan 2016 22:47:31 +0100, duane@duaneellis.com wrote:
> > The distribution you are using (ie: I'm using Ubuntu) should *NOT* compile
> > these files for GLIBC with debug records turned on
> +
> On Thu, 14 Jan 2016 22:55:49 +0100, Mike Frysinger wrote:
> > that is a generated file from glibc, and having its source isn't really useful.
> 
> I am very surprised by this reaction.

why ?  i'm talking about this one specific file which is literally generated
assembly code for a syscall trampoline.  let's look at one example: msgctl
on x86_64.

$ ar x /usr/lib64/libc.a msgctl.o
$ objdump -dr msgctl.o

msgctl.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <__msgctl>:
   0:	b8 47 00 00 00       	mov    $0x47,%eax
   5:	0f 05                	syscall 
   7:	48 3d 01 f0 ff ff    	cmp    $0xfffffffffffff001,%rax
   d:	0f 83 00 00 00 00    	jae    13 <__msgctl+0x13>
			f: R_X86_64_PC32	__syscall_error-0x4
  13:	c3                   	retq   

what exactly do you expect the syscall-template.S to provide that is useful ?
here's the file in case you were wondering:
...
#if SYSCALL_CANCELLABLE
# include <sysdep-cancel.h>
#else
# include <sysdep.h>
#endif

/* This indirection is needed so that SYMBOL gets macro-expanded.  */
#define syscall_hidden_def(SYMBOL)		hidden_def (SYMBOL)

#define T_PSEUDO(SYMBOL, NAME, N)		PSEUDO (SYMBOL, NAME, N)
#define T_PSEUDO_NOERRNO(SYMBOL, NAME, N)	PSEUDO_NOERRNO (SYMBOL, NAME, N)
#define T_PSEUDO_ERRVAL(SYMBOL, NAME, N)	PSEUDO_ERRVAL (SYMBOL, NAME, N)
#define T_PSEUDO_END(SYMBOL)			PSEUDO_END (SYMBOL)
#define T_PSEUDO_END_NOERRNO(SYMBOL)		PSEUDO_END_NOERRNO (SYMBOL)
#define T_PSEUDO_END_ERRVAL(SYMBOL)		PSEUDO_END_ERRVAL (SYMBOL)

#if SYSCALL_NOERRNO

/* This kind of system call stub never returns an error.
   We return the return value register to the caller unexamined.  */

T_PSEUDO_NOERRNO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
	ret_NOERRNO
T_PSEUDO_END_NOERRNO (SYSCALL_SYMBOL)

#elif SYSCALL_ERRVAL

/* This kind of system call stub returns the errno code as its return
   value, or zero for success.  We may massage the kernel's return value
   to meet that ABI, but we never set errno here.  */

T_PSEUDO_ERRVAL (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
	ret_ERRVAL
T_PSEUDO_END_ERRVAL (SYSCALL_SYMBOL)

#else

/* This is a "normal" system call stub: if there is an error,
   it returns -1 and sets errno.  */

T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
	ret
T_PSEUDO_END (SYSCALL_SYMBOL)

#endif

syscall_hidden_def (SYSCALL_SYMBOL)
...

if anything, using disassemble on the function directly is way more useful
and readable.
-mike

Attachment: signature.asc
Description: Digital signature


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