From 15eb317be224984d5206eeebd09e5f2111c1fdf7 Mon Sep 17 00:00:00 2001 From: yangao1 Date: Tue, 20 May 2025 20:55:06 +0800 Subject: [PATCH] libc/arm64: add cfi for optimized func (gdb) bt #0 arch_strlen () at machine/arm64/gnu/arch_strlen.S:119 #1 0x000000004043a2c0 in strchr (s=s@entry=0x408e5e40 "HELLO WORLD", c=c@entry=87) at machine/arch_libc.c:252 #2 0x0000000040504c6c in strchr (c=87, s=0x408e5e40 "HELLO WORLD") at /home/mi/ssd/dev-system/nuttx/include/string.h:306 #3 test_strchr () at hello_main.c:79 #4 hello_main (argc=argc@entry=1, argv=argv@entry=0x40b5c090) at hello_main.c:132 #5 0x000000004043d958 in nxtask_startup (entrypt=0x40504ba0 , argc=argc@entry=1, argv=argv@entry=0x40b5c090) at sched/task_startup.c:72 #6 0x00000000403f1ab4 in nxtask_start () at task/task_start.c:104 #7 0x0000000000000000 in ?? () Signed-off-by: yangao1 --- libs/libc/machine/arm64/arch_memchr.S | 3 +++ libs/libc/machine/arm64/arch_memcmp.S | 3 +++ libs/libc/machine/arm64/arch_memcpy.S | 3 +++ libs/libc/machine/arm64/arch_memmove.S | 3 +++ libs/libc/machine/arm64/arch_memset.S | 3 +++ libs/libc/machine/arm64/arch_strchr.S | 3 +++ libs/libc/machine/arm64/arch_strchrnul.S | 3 +++ libs/libc/machine/arm64/arch_strcmp.S | 3 +++ libs/libc/machine/arm64/arch_strcpy.S | 3 +++ libs/libc/machine/arm64/arch_strlen.S | 3 +++ libs/libc/machine/arm64/arch_strncmp.S | 3 +++ libs/libc/machine/arm64/arch_strnlen.S | 3 +++ libs/libc/machine/arm64/arch_strrchr.S | 3 +++ 13 files changed, 39 insertions(+) diff --git a/libs/libc/machine/arm64/arch_memchr.S b/libs/libc/machine/arm64/arch_memchr.S index 98275f5f11a..576a31fc824 100644 --- a/libs/libc/machine/arm64/arch_memchr.S +++ b/libs/libc/machine/arm64/arch_memchr.S @@ -81,6 +81,8 @@ .endm def_fn ARCH_LIBCFUN(memchr) + .cfi_sections .debug_frame + .cfi_startproc /* Do not dereference srcin if no bytes to compare. */ cbz cntin, .Lzero_length /* @@ -174,6 +176,7 @@ def_fn ARCH_LIBCFUN(memchr) mov result, #0 ret + .cfi_endproc .size ARCH_LIBCFUN(memchr), . - ARCH_LIBCFUN(memchr) #endif diff --git a/libs/libc/machine/arm64/arch_memcmp.S b/libs/libc/machine/arm64/arch_memcmp.S index bb7429d36a3..76bb2706069 100644 --- a/libs/libc/machine/arm64/arch_memcmp.S +++ b/libs/libc/machine/arm64/arch_memcmp.S @@ -95,6 +95,8 @@ .endm def_fn ARCH_LIBCFUN(memcmp) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc subs limit, limit, 8 b.lo L(less8) @@ -197,6 +199,7 @@ L(byte_loop): sub result, data1w, data2w ret + .cfi_endproc .size ARCH_LIBCFUN(memcmp), . - ARCH_LIBCFUN(memcmp) #endif diff --git a/libs/libc/machine/arm64/arch_memcpy.S b/libs/libc/machine/arm64/arch_memcpy.S index 1acb7f04ab9..4eaf1532cbd 100644 --- a/libs/libc/machine/arm64/arch_memcpy.S +++ b/libs/libc/machine/arm64/arch_memcpy.S @@ -112,6 +112,8 @@ */ def_fn ARCH_LIBCFUN(memcpy) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc prfm PLDL1KEEP, [src] add srcend, src, count add dstend, dstin, count @@ -233,6 +235,7 @@ L(copy_long): stp C_l, C_h, [dstend, -16] ret + .cfi_endproc .size ARCH_LIBCFUN(memcpy), . - ARCH_LIBCFUN(memcpy) #endif diff --git a/libs/libc/machine/arm64/arch_memmove.S b/libs/libc/machine/arm64/arch_memmove.S index 557185599be..a18bd65bb55 100644 --- a/libs/libc/machine/arm64/arch_memmove.S +++ b/libs/libc/machine/arm64/arch_memmove.S @@ -101,6 +101,8 @@ */ def_fn ARCH_LIBCFUN(memmove), 6 + .cfi_sections .debug_frame + .cfi_startproc sub tmp1, dstin, src cmp count, 96 ccmp tmp1, count, 2, hi @@ -158,6 +160,7 @@ def_fn ARCH_LIBCFUN(memmove), 6 stp C_l, C_h, [dstin] 3: ret + .cfi_endproc .size ARCH_LIBCFUN(memmove), . - ARCH_LIBCFUN(memmove) #endif diff --git a/libs/libc/machine/arm64/arch_memset.S b/libs/libc/machine/arm64/arch_memset.S index deb4626001d..7c81ae77efd 100644 --- a/libs/libc/machine/arm64/arch_memset.S +++ b/libs/libc/machine/arm64/arch_memset.S @@ -94,6 +94,8 @@ def_fn ARCH_LIBCFUN(memset) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc dup v0.16B, valw add dstend, dstin, count @@ -243,6 +245,7 @@ L(zva_other): sub dst, dst, 32 /* Bias dst for tail loop. */ b L(tail64) + .cfi_endproc .size ARCH_LIBCFUN(memset), . - ARCH_LIBCFUN(memset) #endif diff --git a/libs/libc/machine/arm64/arch_strchr.S b/libs/libc/machine/arm64/arch_strchr.S index 3e7ae0a2250..0f62d19344e 100644 --- a/libs/libc/machine/arm64/arch_strchr.S +++ b/libs/libc/machine/arm64/arch_strchr.S @@ -85,6 +85,8 @@ .endm def_fn ARCH_LIBCFUN(strchr) + .cfi_sections .debug_frame + .cfi_startproc /* Magic constant 0x40100401 to allow us to identify which lane matches the requested byte. Magic constant 0x80200802 used similarly for NUL termination. */ @@ -162,6 +164,7 @@ def_fn ARCH_LIBCFUN(strchr) csel result, result, xzr, eq ret + .cfi_endproc .size ARCH_LIBCFUN(strchr), . - ARCH_LIBCFUN(strchr) #endif diff --git a/libs/libc/machine/arm64/arch_strchrnul.S b/libs/libc/machine/arm64/arch_strchrnul.S index 0376f1a3a61..3c3ea8c818a 100644 --- a/libs/libc/machine/arm64/arch_strchrnul.S +++ b/libs/libc/machine/arm64/arch_strchrnul.S @@ -81,6 +81,8 @@ .endm def_fn ARCH_LIBCFUN(strchrnul) + .cfi_sections .debug_frame + .cfi_startproc /* Magic constant 0x40100401 to allow us to identify which lane matches the termination condition. */ mov wtmp2, #0x0401 @@ -147,6 +149,7 @@ def_fn ARCH_LIBCFUN(strchrnul) add result, src, tmp1, lsr #1 ret + .cfi_endproc .size ARCH_LIBCFUN(strchrnul), . - ARCH_LIBCFUN(strchrnul) #endif diff --git a/libs/libc/machine/arm64/arch_strcmp.S b/libs/libc/machine/arm64/arch_strcmp.S index 395234fa950..e4f1d2f52b1 100644 --- a/libs/libc/machine/arm64/arch_strcmp.S +++ b/libs/libc/machine/arm64/arch_strcmp.S @@ -77,6 +77,8 @@ /* Start of performance-critical section -- one 64B cache line. */ def_fn ARCH_LIBCFUN(strcmp) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc eor tmp1, src1, src2 mov zeroones, #REP8_01 tst tmp1, #7 @@ -206,6 +208,7 @@ L(loop_misaligned): L(done): sub result, data1, data2 ret + .cfi_endproc .size ARCH_LIBCFUN(strcmp), .-ARCH_LIBCFUN(strcmp) #endif diff --git a/libs/libc/machine/arm64/arch_strcpy.S b/libs/libc/machine/arm64/arch_strcpy.S index 7543494ec46..69f026755ca 100644 --- a/libs/libc/machine/arm64/arch_strcpy.S +++ b/libs/libc/machine/arm64/arch_strcpy.S @@ -108,6 +108,8 @@ #define MIN_PAGE_SIZE (1 << MIN_PAGE_P2) def_fn ARCH_LIBCFUN(strcpy) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc /* For moderately short strings, the fastest way to do the copy is to calculate the length of the string in the same way as strlen, then essentially do a memcpy of the result. This avoids the need for @@ -321,6 +323,7 @@ def_fn ARCH_LIBCFUN(strcpy) p2align=6 bic has_nul2, tmp3, tmp4 b .Lfp_gt8 + .cfi_endproc .size ARCH_LIBCFUN(strcpy), . - ARCH_LIBCFUN(strcpy) #endif diff --git a/libs/libc/machine/arm64/arch_strlen.S b/libs/libc/machine/arm64/arch_strlen.S index 23a8a44aeb4..36f107a6207 100644 --- a/libs/libc/machine/arm64/arch_strlen.S +++ b/libs/libc/machine/arm64/arch_strlen.S @@ -114,6 +114,8 @@ boundary. */ def_fn ARCH_LIBCFUN(strlen) p2align=6 + .cfi_sections .debug_frame + .cfi_startproc and tmp1, srcin, MIN_PAGE_SIZE - 1 mov zeroones, REP8_01 cmp tmp1, MIN_PAGE_SIZE - 16 @@ -243,6 +245,7 @@ L(page_cross): csel data2, data2, tmp2, eq b L(page_cross_entry) + .cfi_endproc .size ARCH_LIBCFUN(strlen), . - ARCH_LIBCFUN(strlen) #endif diff --git a/libs/libc/machine/arm64/arch_strncmp.S b/libs/libc/machine/arm64/arch_strncmp.S index 62a3250e942..f4016bd7e39 100644 --- a/libs/libc/machine/arm64/arch_strncmp.S +++ b/libs/libc/machine/arm64/arch_strncmp.S @@ -84,6 +84,8 @@ nop /* Pad so that the loop below fits a cache line. */ .endr def_fn ARCH_LIBCFUN(strncmp) + .cfi_sections .debug_frame + .cfi_startproc cbz limit, .Lret0 eor tmp1, src1, src2 mov zeroones, #REP8_01 @@ -295,6 +297,7 @@ def_fn ARCH_LIBCFUN(strncmp) .Lret0: mov result, #0 ret + .cfi_endproc .size ARCH_LIBCFUN(strncmp), . - ARCH_LIBCFUN(strncmp) #endif diff --git a/libs/libc/machine/arm64/arch_strnlen.S b/libs/libc/machine/arm64/arch_strnlen.S index 3077b6d2f3a..a93267394b9 100644 --- a/libs/libc/machine/arm64/arch_strnlen.S +++ b/libs/libc/machine/arm64/arch_strnlen.S @@ -87,6 +87,8 @@ ret def_fn ARCH_LIBCFUN(strnlen) + .cfi_sections .debug_frame + .cfi_startproc cbz limit, .Lhit_limit mov zeroones, #REP8_01 bic src, srcin, #15 @@ -189,6 +191,7 @@ def_fn ARCH_LIBCFUN(strnlen) csinv data1, data1, xzr, le csel data2, data2, data2a, le b .Lrealigned + .cfi_endproc .size ARCH_LIBCFUN(strnlen), . - .Lstart /* Include pre-padding in size. */ #endif diff --git a/libs/libc/machine/arm64/arch_strrchr.S b/libs/libc/machine/arm64/arch_strrchr.S index 9208d1cc68a..5e4ae80f18d 100644 --- a/libs/libc/machine/arm64/arch_strrchr.S +++ b/libs/libc/machine/arm64/arch_strrchr.S @@ -91,6 +91,8 @@ .endm def_fn ARCH_LIBCFUN(strrchr) + .cfi_sections .debug_frame + .cfi_startproc /* Magic constant 0x40100401 to allow us to identify which lane matches the requested byte. Magic constant 0x80200802 used similarly for NUL termination. */ @@ -180,6 +182,7 @@ def_fn ARCH_LIBCFUN(strrchr) ret + .cfi_endproc .size ARCH_LIBCFUN(strrchr), . - ARCH_LIBCFUN(strrchr) #endif