Skip to content

Commit 28e32df

Browse files
parport0ldv-alt
authored andcommitted
Add unique syscall entry numbers (SENs)
* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sen.h. (syscallent_names, syscallent_patterns, syscallent_files): New variables. (sen.h): New rule. * defs.h (struct sysent): Add sen field. * generate_sen.sh: New file. * linux/syscall.h: Include "sen.h". * syscall.c (SEN_NAME): New temporary macro. (SEN): Use it to prepend syscall entry number.
1 parent 140ecf8 commit 28e32df

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

Makefile.am

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ EXTRA_DIST = \
163163
debian/strace64.manpages \
164164
debian/watch \
165165
errnoent.sh \
166+
generate_sen.sh \
166167
ioctlsort.c \
167168
linux/32/ioctls_inc.h \
168169
linux/32/ioctls_inc_align32.h \
@@ -567,7 +568,7 @@ EXTRA_DIST = \
567568
srpm: dist-xz
568569
rpmbuild --define '%_srcrpmdir .' -ts $(distdir).tar.xz
569570

570-
BUILT_SOURCES = .version sys_func.h
571+
BUILT_SOURCES = .version sys_func.h sen.h
571572

572573
$(srcdir)/.version:
573574
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@
@@ -579,6 +580,15 @@ sys_func.h: $(patsubst %,$(srcdir)/%,$(strace_SOURCES_c))
579580
sed -n 's/^SYS_FUNC(.*/extern &;/p' $$f; \
580581
done | sort -u > $@
581582

583+
syscallent_names = subcall.h syscallent.h syscallent1.h \
584+
syscallent-n32.h syscallent-n64.h syscallent-o32.h
585+
syscallent_patterns = $(patsubst %,\%/%,$(syscallent_names))
586+
syscallent_files = $(filter $(syscallent_patterns),$(EXTRA_DIST))
587+
588+
sen.h: $(patsubst %,$(srcdir)/%,$(syscallent_files))
589+
for f in $^; do cat -- $$f; done | \
590+
$(srcdir)/generate_sen.sh > $@
591+
582592
dist-hook:
583593
$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
584594

@@ -605,7 +615,7 @@ ioctlsort_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_FOR_BUILD)
605615
ioctls_inc_h = $(wildcard $(srcdir)/$(OS)/$(ARCH)/ioctls_inc*.h)
606616
ioctlent_h = $(patsubst $(srcdir)/$(OS)/$(ARCH)/ioctls_inc%,ioctlent%,$(ioctls_inc_h))
607617
BUILT_SOURCES += $(ioctlent_h)
608-
CLEANFILES = sys_func.h $(ioctlent_h)
618+
CLEANFILES = sys_func.h sen.h $(ioctlent_h)
609619

610620
ioctlent%.h: ioctlsort%
611621
./$< > $@

defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ extern char *stpcpy(char *dst, const char *src);
249249
typedef struct sysent {
250250
unsigned nargs;
251251
int sys_flags;
252+
int sen;
252253
int (*sys_func)();
253254
const char *sys_name;
254255
} struct_sysent;

generate_sen.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh -e
2+
3+
echo 'enum {'
4+
echo 'SEN_printargs = 0,'
5+
sed -n '/printargs/! s/.*SEN(\([^)]*\)).*/\1/p' |
6+
sort -u |
7+
sed 's/.*/SEN_&,/'
8+
echo '};'

linux/syscall.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "dummy.h"
3030
#include "sys_func.h"
31+
#include "sen.h"
3132

3233
#if NEED_UID16_PARSERS
3334
extern SYS_FUNC(chown16);

syscall.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
#define SI STACKTRACE_INVALIDATE_CACHE
8282
#define SE STACKTRACE_CAPTURE_ON_ENTER
8383

84-
#define SEN(syscall_name) SYS_FUNC_NAME(syscall_name)
84+
#define SEN_NAME(syscall_name) SEN_ ## syscall_name
85+
#define SEN(syscall_name) SEN_NAME(syscall_name), SYS_FUNC_NAME(syscall_name)
8586

8687
const struct_sysent sysent0[] = {
8788
#include "syscallent.h"
@@ -101,6 +102,7 @@ static const struct_sysent sysent2[] = {
101102

102103
/* Now undef them since short defines cause wicked namespace pollution. */
103104
#undef SEN
105+
#undef SEN_NAME
104106
#undef TD
105107
#undef TF
106108
#undef TI

0 commit comments

Comments
 (0)