aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2021-11-13 20:38:18 -0800
committerAndrew G. Morgan <morgan@kernel.org>2021-11-13 20:44:13 -0800
commitc234bf90839f19e0332b586335411cb626a25a18 (patch)
treed3feb41a7a0925e430bf49299439c4eebc36b6de
parent0c463bf38d48dd9b725a5fa491e0728e04c37b94 (diff)
downloadlibcap-c234bf90839f19e0332b586335411cb626a25a18.tar.gz
Work around a __i386__ compilation issue for runnable .so files.
This was reported by Sam James and debugged with respect to: https://bugs.gentoo.org/show_bug.cgi?id=820071 Modern versions of glibc employ SSE instructions that require the stack to be aligned to 16 bytes in order to execute movaps and friends to stack stored memory. The ABI for x86_64 requires this alignment so we'd not seen this issue before being cc:d into the bug. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--libcap/execable.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/libcap/execable.h b/libcap/execable.h
index 0bcc5d4..229dd2f 100644
--- a/libcap/execable.h
+++ b/libcap/execable.h
@@ -74,20 +74,26 @@ static void __execable_parse_args(int *argc_p, char ***argv_p)
* Note, to avoid any runtime confusion, SO_MAIN is a void static
* function.
*/
+#if defined(__i386__)
+#define __SO_FORCE_ARG_ALIGNMENT __attribute__((force_align_arg_pointer))
+#else
+#define __SO_FORCE_ARG_ALIGNMENT
+#endif /* def __i386 */
-#define SO_MAIN \
-static void __execable_main(int, char**); \
-extern void __so_start(void); \
-void __so_start(void) \
-{ \
- int argc; \
- char **argv; \
- __execable_parse_args(&argc, &argv); \
+#define SO_MAIN \
+static void __execable_main(int, char**); \
+extern void __so_start(void); \
+__SO_FORCE_ARG_ALIGNMENT \
+void __so_start(void) \
+{ \
+ int argc; \
+ char **argv; \
+ __execable_parse_args(&argc, &argv); \
__execable_main(argc, argv); \
- if (argc != 0) { \
- free(argv[0]); \
- free(argv); \
- } \
- exit(0); \
-} \
+ if (argc != 0) { \
+ free(argv[0]); \
+ free(argv); \
+ } \
+ exit(0); \
+} \
static void __execable_main