clang emits this warning when compiling brk.S and sbrk.S on riscv64:

/tmp/sbrk-06c40b.s:46:2: warning: sbrk changed binding to STB_WEAK
 .weak sbrk

Let's avoid this using the "ENTRY_NB" approach implemented by guenther@
on other archs.  Diff tailored to reduce the differences with
arm64/include/asm.h (that's why I swapped .p2align and .type).

ok?


Index: sys/arch/riscv64/include/asm.h
===================================================================
RCS file: /cvs/src/sys/arch/riscv64/include/asm.h,v
retrieving revision 1.6
diff -u -p -r1.6 asm.h
--- sys/arch/riscv64/include/asm.h      2 Dec 2022 12:27:08 -0000       1.6
+++ sys/arch/riscv64/include/asm.h      2 Dec 2022 20:00:49 -0000
@@ -53,6 +53,11 @@
 # define _ALIGN_TEXT .align 0
 #endif
 
+/* NB == No Binding: use .globl or .weak as necessary */
+#define _ENTRY_NB(x) \
+       .text; .p2align 1; .type x,@function; x:
+#define _ENTRY(x)      .globl x; _ENTRY_NB(x)
+
 #if defined(PROF) || defined(GPROF)
 // XXX Profiler Support
 #define _PROF_PROLOGUE                 \
@@ -81,10 +86,9 @@
 #define RETGUARD_SYMBOL(x)
 #endif
 
-#define        _ENTRY(x)                                                       
\
-       .text; .globl x; .type x,@function; .p2align 1; x:
 #define        ENTRY(y)        _ENTRY(y); _PROF_PROLOGUE
 #define        ENTRY_NP(y)     _ENTRY(y)
+#define        ENTRY_NB(y)     _ENTRY_NB(y); _PROF_PROLOGUE
 #define        ASENTRY(y)      _ENTRY(y); _PROF_PROLOGUE
 #define        ASENTRY_NP(y)   _ENTRY(y)
 #define        END(y)          .size y, . - y
Index: lib/libc/arch/riscv64/sys/brk.S
===================================================================
RCS file: /cvs/src/lib/libc/arch/riscv64/sys/brk.S,v
retrieving revision 1.3
diff -u -p -r1.3 brk.S
--- lib/libc/arch/riscv64/sys/brk.S     2 Dec 2022 12:27:08 -0000       1.3
+++ lib/libc/arch/riscv64/sys/brk.S     2 Dec 2022 16:25:32 -0000
@@ -26,7 +26,7 @@ __minbrk:
        .dword _end
        
 
-ENTRY(brk)
+ENTRY_NB(brk)
        RETGUARD_SETUP(brk, t6)
        lla     t1, __minbrk
        ld      t5, 0(t1)
Index: lib/libc/arch/riscv64/sys/sbrk.S
===================================================================
RCS file: /cvs/src/lib/libc/arch/riscv64/sys/sbrk.S,v
retrieving revision 1.3
diff -u -p -r1.3 sbrk.S
--- lib/libc/arch/riscv64/sys/sbrk.S    2 Dec 2022 12:27:08 -0000       1.3
+++ lib/libc/arch/riscv64/sys/sbrk.S    2 Dec 2022 16:25:50 -0000
@@ -28,7 +28,7 @@ __curbrk:
        .dword _end
        END(__curbrk)
        
-ENTRY(sbrk)
+ENTRY_NB(sbrk)
        RETGUARD_SETUP(sbrk, t6)
 
        lla     t1, __curbrk

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to