This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: How can I declare a global variable related to syscall routines without any issue?
- From: Bbbb Im <bjspam dot im at gmail dot com>
- To: Paul Pluzhnikov <ppluzhnikov at google dot com>
- Cc: libc-help <libc-help at sourceware dot org>
- Date: Sun, 29 Dec 2019 20:31:29 -0600
- Subject: Re: How can I declare a global variable related to syscall routines without any issue?
- References: <CAMfc50T3GKKX6WMqspi5xBUQaCW57aj9gnOy6X1e_QnbPbbXvg@mail.gmail.com> <CALoOobMujc6rAUvyPLw9Y4k69x5=E4D=CkXZJWMrzkDXsXXPAw@mail.gmail.com>
Simply, I want, on some occasions, something else should be executed rather
than the original syscall instruction.
For example, in sysdeps/unix/sysv/linux/x86_64/sysdep.h;
#define internal_syscall0(number, err, dummy...) \
({ \
unsigned long int resultvar; \
if (!my_flag) { \
asm volatile ( \
"syscall\n\t" \
: "=a" (resultvar) \
: "0" (number) \
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
} else { \
asm volatile ( \
something else here .... ); \
} \
(long int) resultvar; \
})
I want 'my_flag' is set/unset by my newly created API and any syscalls
should be altered by those "something else here" thing.
Thank you.
2019년 12월 29일 (일) 오후 8:20, Paul Pluzhnikov <ppluzhnikov@google.com>님이 작성:
> On Sun, Dec 29, 2019 at 4:19 PM Bbbb Im <bjspam.im@gmail.com> wrote:
> >
> > Hi
> >
> > I am trying to modify x86-64 syscall routines to behave conditionally by
> a
> > flag variable.
>
> What are you trying to achieve?
> See also http://xyproblem.info/
>
> > To do that, I added simple if statements in the
> > internal_syscall macros to check the value of the flag.
> > However, since they are macros, I need to declare the flag variable as a
> > global variable somewhere, then add "extern int" declaration in all C
> files
> > which call syscalll macros, and the object code which has the declaration
> > should be linked to all the objs with "extern" statements.
> > The problem is that which C file is the best place to declare the flag
> as a
> > global variable that does not break anything and linked to all the sycall
> > related C files? I could modify makefiles to link the declared obj files
> to
> > be linked to all others, but I am not sure it's the correct way to do it.
> >
> > Thank you.
>
>
>
> --
> Paul Pluzhnikov
>