fix generating syscall-names.h for loongarch64
authorWeijie Gao <[email protected]>
Sat, 14 Jun 2025 15:01:55 +0000 (23:01 +0800)
committerHauke Mehrtens <[email protected]>
Thu, 19 Jun 2025 20:21:54 +0000 (22:21 +0200)
The <bits/syscall.h> from musl loongarch64 arch contains some
indirect syscall definitions:
 #define __NR3264_fcntl                  25
 #define __NR_fcntl                      __NR3264_fcntl

This will result in incorrect contents generated by make_syscall_h_sh:
 [__NR3264_fcntl] = "fcntl",

To fix this issue, all macros staring with __NR3264_ should be also
copied to the generated syscall-names.h

Signed-off-by: Weijie Gao <[email protected]>
make_syscall_h.sh

index 17e3bc472b8f9678bfcbfc0e04ac8cfddfe0e1e9..6e2161c040d8fdc955c967a6c557637a16eb76d4 100755 (executable)
@@ -12,6 +12,10 @@ CC=$1
 [ -n "$TARGET_CC_NOCACHE" ] && CC=$TARGET_CC_NOCACHE
 
 echo "#include <asm/unistd.h>"
+
+# for loongarch __NR3264_* macros
+echo "#include <sys/syscall.h>" | ${CC} -E -dM - | grep '^#define __NR3264_[a-z0-9_]\+[ \t].*[0-9].*$'
+
 echo "static const char *__syscall_names[] = {"
 echo "#include <sys/syscall.h>" | ${CC} -E -dM - | grep '^#define __NR_[a-z0-9_]\+[ \t].*[0-9].*$' | \
        LC_ALL=C sed -r -n -e 's/^\#define[ \t]+__NR_([a-z0-9_]+)[ \t]+([ ()+0-9a-zNR_LSYCABE]+)(.*)/ [\2] = "\1",/p'