From 6026980cac8bf016fb094ca3ad72bebb4d6bfb43 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 8 Jan 2021 04:18:21 +0100 Subject: [PATCH] ppc, ppc64: tag global symbols as functions it is necessary to tag these symbols as functions otherwise the linker gets confused; this previously manifested as the internal functions (pre-rename) like __getcontext leaking into the symbol table of things linked against libucontext that used the ucontext POSIX API through the weak aliases it also had another bad effect and that is if you tried to use libucontext's API (post-rename), the linker would warn you during compile time that the type is unknown, and the resulting program would crash at runtime after properly tagging everything, I no longer notice any leakage, i.e. there don't seem to be any references to the aliased symbols in the resulting symbol table when using the aliases, and using the libucontext prefixed symbols directly also works --- arch/ppc/getcontext.S | 1 + arch/ppc/setcontext.S | 1 + arch/ppc/swapcontext.S | 1 + arch/ppc64/getcontext.S | 1 + arch/ppc64/setcontext.S | 1 + arch/ppc64/swapcontext.S | 1 + 6 files changed, 6 insertions(+) diff --git a/arch/ppc/getcontext.S b/arch/ppc/getcontext.S index 5e16a1c..034704c 100644 --- a/arch/ppc/getcontext.S +++ b/arch/ppc/getcontext.S @@ -12,6 +12,7 @@ .global libucontext_getcontext .hidden __libucontext_swapcontext +.type libucontext_getcontext, @function libucontext_getcontext: li 4, 0 b __libucontext_swapcontext@local diff --git a/arch/ppc/setcontext.S b/arch/ppc/setcontext.S index 325b715..7a612f9 100644 --- a/arch/ppc/setcontext.S +++ b/arch/ppc/setcontext.S @@ -12,6 +12,7 @@ .global libucontext_setcontext .hidden __libucontext_swapcontext +.type libucontext_setcontext, @function libucontext_setcontext: mr 4, 3 li 3, 0 diff --git a/arch/ppc/swapcontext.S b/arch/ppc/swapcontext.S index 69cc60e..25d7aa5 100644 --- a/arch/ppc/swapcontext.S +++ b/arch/ppc/swapcontext.S @@ -11,6 +11,7 @@ */ .global __libucontext_swapcontext +.type __libucontext_swapcontext, @function __libucontext_swapcontext: li 0, 249 # SYS_swapcontext li 5, 1184 # sizeof(ucontext_t) diff --git a/arch/ppc64/getcontext.S b/arch/ppc64/getcontext.S index 194aaa0..87321af 100644 --- a/arch/ppc64/getcontext.S +++ b/arch/ppc64/getcontext.S @@ -12,6 +12,7 @@ .global libucontext_getcontext .hidden __libucontext_swapcontext +.type libucontext_getcontext, @function libucontext_getcontext: addis 2, 12, .TOC.-libucontext_getcontext@ha addi 2, 12, .TOC.-libucontext_getcontext@l diff --git a/arch/ppc64/setcontext.S b/arch/ppc64/setcontext.S index a2fb2ad..c8aa584 100644 --- a/arch/ppc64/setcontext.S +++ b/arch/ppc64/setcontext.S @@ -12,6 +12,7 @@ .global libucontext_setcontext .hidden __libucontext_swapcontext +.type libucontext_setcontext, @function libucontext_setcontext: addis 2, 12, .TOC.-libucontext_setcontext@ha addi 2, 12, .TOC.-libucontext_setcontext@l diff --git a/arch/ppc64/swapcontext.S b/arch/ppc64/swapcontext.S index e7d2fec..554ac55 100644 --- a/arch/ppc64/swapcontext.S +++ b/arch/ppc64/swapcontext.S @@ -11,6 +11,7 @@ */ .global __libucontext_swapcontext +.type __libucontext_swapcontext, @function __libucontext_swapcontext: addis 2, 12, .TOC.-__libucontext_swapcontext@ha addi 2, 12, .TOC.-__libucontext_swapcontext@l