From 0be5e928845b741c9c0f7c1669bc1b98078d4dae Mon Sep 17 00:00:00 2001 From: guenther Date: Fri, 10 Jun 2022 01:56:02 +0000 Subject: [PATCH] Add _?ENTRY_NB() macro for doing an ASM function entry without setting the binding to global (NB == "no binding"), as clang 13 is now warning about changing the binding from global to weak. Use them for bcopy, brk, and sbrk. Add the '.L' prefix to internal labels in the bcopy implementation to remove them from the symbol table Start using the MI DEFS.h: delete the #defines from powerpc/SYS.h that the MI DEFS.h provides and switch from SYS.h to DEFS.h in files that don't do syscalls. Use END_BUILTIN from the MI DEFS.h for ffs. ok gkoehler@ --- lib/libc/arch/powerpc/SYS.h | 26 +---------- lib/libc/arch/powerpc/gen/setjmp.S | 3 +- lib/libc/arch/powerpc/gen/sigsetjmp.S | 3 +- lib/libc/arch/powerpc/string/ffs.S | 7 ++- lib/libc/arch/powerpc/string/memmove.S | 64 +++++++++++++------------- lib/libc/arch/powerpc/sys/brk.S | 4 +- lib/libc/arch/powerpc/sys/sbrk.S | 4 +- sys/arch/powerpc/include/asm.h | 8 ++-- 8 files changed, 48 insertions(+), 71 deletions(-) diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h index 053728a6395..f7fae8ba6da 100644 --- a/lib/libc/arch/powerpc/SYS.h +++ b/lib/libc/arch/powerpc/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.25 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: SYS.h,v 1.26 2022/06/10 01:56:02 guenther Exp $ */ /*- * Copyright (c) 1994 * Andrew Cagney. All rights reserved. @@ -42,7 +42,7 @@ /* r0 will be a non zero errno if there was an error, while r3/r4 will contain the return value */ -#include "machine/asm.h" +#include "DEFS.h" /* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */ @@ -53,28 +53,6 @@ /* offset of errno from %r2 */ #define R2_OFFSET_ERRNO (-TCB_OFFSET + TCB_OFFSET_ERRNO) -/* - * We define a hidden alias with the prefix "_libc_" for each global symbol - * that may be used internally. By referencing _libc_x instead of x, other - * parts of libc prevent overriding by the application and avoid unnecessary - * relocations. - */ -#define _HIDDEN(x) _libc_##x -#define _HIDDEN_ALIAS(x,y) \ - STRONG_ALIAS(_HIDDEN(x),y); \ - .hidden _HIDDEN(x) -#define _HIDDEN_FALIAS(x,y) \ - _HIDDEN_ALIAS(x,y); \ - .type _HIDDEN(x),@function - -/* - * For functions implemented in ASM that aren't syscalls. - * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names - * END_WEAK(x) Like DEF_WEAK() in C; for non-ISO C names - */ -#define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) -#define END_WEAK(x) END_STRONG(x); .weak x - #define SYSENTRY(x) WEAK_ALIAS(x, _thread_sys_ ## x); \ ENTRY(_thread_sys_ ## x) #define SYSENTRY_HIDDEN(x) ENTRY(_thread_sys_ ## x) diff --git a/lib/libc/arch/powerpc/gen/setjmp.S b/lib/libc/arch/powerpc/gen/setjmp.S index 6da84b17fb4..e62121eec92 100644 --- a/lib/libc/arch/powerpc/gen/setjmp.S +++ b/lib/libc/arch/powerpc/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.13 2016/05/29 07:59:36 guenther Exp $ */ +/* $OpenBSD: setjmp.S,v 1.14 2022/06/10 01:56:02 guenther Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -25,7 +25,6 @@ */ #include "SYS.h" -#include /* int setjmp(jmp_buf env) */ diff --git a/lib/libc/arch/powerpc/gen/sigsetjmp.S b/lib/libc/arch/powerpc/gen/sigsetjmp.S index 2667c711705..db10a1a8330 100644 --- a/lib/libc/arch/powerpc/gen/sigsetjmp.S +++ b/lib/libc/arch/powerpc/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.7 2016/05/22 23:56:30 guenther Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.8 2022/06/10 01:56:02 guenther Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -25,7 +25,6 @@ */ #include "SYS.h" -#include #define JMP_sigflag 0x00 #define JMP_r1 0x04 diff --git a/lib/libc/arch/powerpc/string/ffs.S b/lib/libc/arch/powerpc/string/ffs.S index 4d6410ebd49..62b7916fc6b 100644 --- a/lib/libc/arch/powerpc/string/ffs.S +++ b/lib/libc/arch/powerpc/string/ffs.S @@ -1,10 +1,10 @@ -/* $OpenBSD: ffs.S,v 1.3 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: ffs.S,v 1.4 2022/06/10 01:56:02 guenther Exp $ */ /* * Written by Christian Weisgerber . * Public domain. */ -#include "SYS.h" +#include "DEFS.h" ENTRY(ffs) RETGUARD_SETUP(ffs, %r11, %r12) @@ -14,5 +14,4 @@ ENTRY(ffs) subfic %r3, %r3, 32 RETGUARD_CHECK(ffs, %r11, %r12) blr -END(ffs) -.protected +END_BUILTIN(ffs) diff --git a/lib/libc/arch/powerpc/string/memmove.S b/lib/libc/arch/powerpc/string/memmove.S index 1aa29c3f544..9d63fab085b 100644 --- a/lib/libc/arch/powerpc/string/memmove.S +++ b/lib/libc/arch/powerpc/string/memmove.S @@ -1,4 +1,4 @@ -/* $OpenBSD: memmove.S,v 1.4 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: memmove.S,v 1.5 2022/06/10 01:56:02 guenther Exp $ */ /* $NetBSD: memmove.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */ /* stropt/memmove.S, pl_string_common, pl_linux 10/11/04 11:45:37 @@ -39,7 +39,7 @@ * ========================================================================== */ -#include "SYS.h" +#include "DEFS.h" .text @@ -48,11 +48,11 @@ ENTRY(memcpy) RETGUARD_SETUP(memmove, %r11, %r12) mr %r8, %r3 /* Save dst (return value) */ - b fwd + b .Lfwd #endif /* void bcopy(void *, void *, size_t) */ -ENTRY(bcopy) +ENTRY_NB(bcopy) mr %r6, %r3 /* swap src/dst */ mr %r3, %r4 mr %r4, %r6 @@ -63,112 +63,112 @@ ENTRY(memmove) mr %r8, %r3 /* Save dst (return value) */ cmpw %r4, %r8 /* Branch to reverse if */ - blt reverse /* src < dest. Don't want to */ + blt .Lreverse /* src < dest. Don't want to */ /* overwrite end of src with */ /* start of dest */ -fwd: +.Lfwd: addi %r4, %r4, -4 /* Back up src and dst pointers */ addi %r8, %r8, -4 /* due to auto-update of 'load' */ srwi. %r9,%r5,2 /* How many words in total cnt */ - beq- last1 /* Handle byte by byte if < 4 */ + beq- .Llast1 /* Handle byte by byte if < 4 */ /* bytes total */ mtctr %r9 /* Count of words for loop */ lwzu %r7, 4(%r4) /* Preload first word */ - b g1 + b .Lg1 -g0: /* Main loop */ +.Lg0: /* Main loop */ lwzu %r7, 4(%r4) /* Load a new word */ stwu %r6, 4(%r8) /* Store previous word */ -g1: +.Lg1: - bdz- last /* Dec cnt, and branch if just */ + bdz- .Llast /* Dec cnt, and branch if just */ /* one word to store */ lwzu %r6, 4(%r4) /* Load another word */ stwu %r7, 4(%r8) /* Store previous word */ - bdnz+ g0 /* Dec cnt, and loop again if */ + bdnz+ .Lg0 /* Dec cnt, and loop again if */ /* more words */ mr %r7, %r6 /* If word count -> 0, then... */ -last: +.Llast: stwu %r7, 4(%r8) /* ... store last word */ -last1: /* Byte-by-byte copy */ +.Llast1: /* Byte-by-byte copy */ clrlwi. %r5,%r5,30 /* If count -> 0, then ... */ - beq done /* we're done */ + beq .Ldone /* we're done */ mtctr %r5 /* else load count for loop */ lbzu %r6, 4(%r4) /* 1st byte: update addr by 4 */ stbu %r6, 4(%r8) /* since we pre-adjusted by 4 */ - bdz- done /* in anticipation of main loop */ + bdz- .Ldone /* in anticipation of main loop */ -last2: +.Llast2: lbzu %r6, 1(%r4) /* But handle the rest by */ stbu %r6, 1(%r8) /* updating addr by 1 */ - bdnz+ last2 - b done + bdnz+ .Llast2 + b .Ldone /* We're here since src < dest. Don't want to overwrite end of */ /* src with start of dest */ -reverse: +.Lreverse: add %r4, %r4, %r5 /* Work from end to beginning */ add %r8, %r8, %r5 /* so add count to string ptrs */ srwi. %r9,%r5,2 /* Words in total count */ - beq- rlast1 /* Handle byte by byte if < 4 */ + beq- .Lrlast1 /* Handle byte by byte if < 4 */ /* bytes total */ mtctr %r9 /* Count of words for loop */ lwzu %r7, -4(%r4) /* Preload first word */ - b rg1 + b .Lrg1 -rg0: /* Main loop */ +.Lrg0: /* Main loop */ lwzu %r7, -4(%r4) /* Load a new word */ stwu %r6, -4(%r8) /* Store previous word */ -rg1: +.Lrg1: - bdz- rlast /* Dec cnt, and branch if just */ + bdz- .Lrlast /* Dec cnt, and branch if just */ /* one word to store */ lwzu %r6, -4(%r4) /* Load another word */ stwu %r7, -4(%r8) /* Store previous word */ - bdnz+ rg0 /* Dec cnt, and loop again if */ + bdnz+ .Lrg0 /* Dec cnt, and loop again if */ /* more words */ mr %r7, %r6 /* If word count -> 0, then... */ -rlast: +.Lrlast: stwu %r7, -4(%r8) /* ... store last word */ -rlast1: /* Byte-by-byte copy */ +.Lrlast1: /* Byte-by-byte copy */ clrlwi. %r5,%r5,30 /* If count -> 0, then... */ - beq done /* ... we're done */ + beq .Ldone /* ... we're done */ mtctr %r5 /* else load count for loop */ -rlast2: +.Lrlast2: lbzu %r6, -1(%r4) /* Handle the rest, byte by */ stbu %r6, -1(%r8) /* byte */ - bdnz+ rlast2 /* Dec ctr, and branch if more */ + bdnz+ .Lrlast2 /* Dec ctr, and branch if more */ /* bytes left */ -done: +.Ldone: RETGUARD_CHECK(memmove, %r11, %r12) blr END_STRONG(memmove) diff --git a/lib/libc/arch/powerpc/sys/brk.S b/lib/libc/arch/powerpc/sys/brk.S index 51b1a14de7b..dbd1c0c7961 100644 --- a/lib/libc/arch/powerpc/sys/brk.S +++ b/lib/libc/arch/powerpc/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.16 2021/10/25 14:38:10 jca Exp $ */ +/* $OpenBSD: brk.S,v 1.17 2022/06/10 01:56:02 guenther Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -30,7 +30,7 @@ .extern __curbrk .extern _C_LABEL(_end) -ENTRY(brk) +ENTRY_NB(brk) /* check >= _end, if not make the call for _end */ #ifndef __PIC__ diff --git a/lib/libc/arch/powerpc/sys/sbrk.S b/lib/libc/arch/powerpc/sys/sbrk.S index 5976629a522..ea26f1ea2c4 100644 --- a/lib/libc/arch/powerpc/sys/sbrk.S +++ b/lib/libc/arch/powerpc/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.15 2021/10/25 14:38:10 jca Exp $ */ +/* $OpenBSD: sbrk.S,v 1.16 2022/06/10 01:56:02 guenther Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -37,7 +37,7 @@ __curbrk: .type __curbrk,@object .text -ENTRY(sbrk) +ENTRY_NB(sbrk) /* call break(__curbrk + size) */ #ifndef __PIC__ diff --git a/sys/arch/powerpc/include/asm.h b/sys/arch/powerpc/include/asm.h index 2e0a7707730..01d238d6b9d 100644 --- a/sys/arch/powerpc/include/asm.h +++ b/sys/arch/powerpc/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.16 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: asm.h,v 1.17 2022/06/10 01:56:02 guenther Exp $ */ /* $NetBSD: asm.h,v 1.1 1996/09/30 16:34:20 ws Exp $ */ /* @@ -69,8 +69,9 @@ # define _TMP_LABEL(x) .L_/**/x #endif -#define _ENTRY(x) \ - .text; .align 2; .globl x; .type x,@function; x: +#define _ENTRY_NB(x) \ + .text; .align 2; .type x,@function; x: +#define _ENTRY(x) .globl x; _ENTRY_NB(x) #if defined(PROF) || defined(GPROF) # define _PROF_PROLOGUE(y) \ @@ -89,6 +90,7 @@ _TMP_LABEL(y):; \ #endif #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE(y) +#define ENTRY_NB(y) _ENTRY_NB(y); _PROF_PROLOGUE(y) #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE(y) #define END(y) .size y, . - y -- 2.20.1