From 678797f0625ea9e7a74aebdc0b7d2afcf3d66e07 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 14 Mar 2024 06:27:06 +0900 Subject: [PATCH] fix fdpic regressions in gcc 10 and later these were added when arm fdpic support was upstreamed in gcc. one patch was just entirely wrong (broke arm init/fini arrays, gcc pr#114158) and the other put arm-specific unwind logic in place for all fdpic targets and broke building of the unwinder code. --- patches/gcc-10.3.0/0007-fdpic-unwind.diff | 11 ++++++ .../0008-fdpic-crtstuff-pr114158.diff | 38 +++++++++++++++++++ patches/gcc-11.2.0/0007-fdpic-unwind.diff | 11 ++++++ .../0008-fdpic-crtstuff-pr114158.diff | 38 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 patches/gcc-10.3.0/0007-fdpic-unwind.diff create mode 100644 patches/gcc-10.3.0/0008-fdpic-crtstuff-pr114158.diff create mode 100644 patches/gcc-11.2.0/0007-fdpic-unwind.diff create mode 100644 patches/gcc-11.2.0/0008-fdpic-crtstuff-pr114158.diff diff --git a/patches/gcc-10.3.0/0007-fdpic-unwind.diff b/patches/gcc-10.3.0/0007-fdpic-unwind.diff new file mode 100644 index 0000000..61d3479 --- /dev/null +++ b/patches/gcc-10.3.0/0007-fdpic-unwind.diff @@ -0,0 +1,11 @@ +--- a/libgcc/unwind-pe.h 2024-03-14 05:59:53.754073149 +0900 ++++ b/libgcc/unwind-pe.h 2024-03-14 06:00:41.226074492 +0900 +@@ -262,7 +262,7 @@ + + if (result != 0) + { +-#if __FDPIC__ ++#if __FDPIC__ && __arm__ + /* FDPIC relative addresses imply taking the GOT address + into account. */ + if ((encoding & DW_EH_PE_pcrel) && (encoding & DW_EH_PE_indirect)) diff --git a/patches/gcc-10.3.0/0008-fdpic-crtstuff-pr114158.diff b/patches/gcc-10.3.0/0008-fdpic-crtstuff-pr114158.diff new file mode 100644 index 0000000..3986eed --- /dev/null +++ b/patches/gcc-10.3.0/0008-fdpic-crtstuff-pr114158.diff @@ -0,0 +1,38 @@ +--- a/libgcc/crtstuff.c 2023-05-29 17:46:32.000000000 +0900 ++++ b/libgcc/crtstuff.c 2024-03-14 06:03:42.398079615 +0900 +@@ -441,17 +441,9 @@ + #ifdef FINI_SECTION_ASM_OP + CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux) + #elif defined (FINI_ARRAY_SECTION_ASM_OP) +-#if defined(__FDPIC__) +-__asm__("\t.equ\t__do_global_dtors_aux_alias, __do_global_dtors_aux\n"); +-extern char __do_global_dtors_aux_alias; +-static void *__do_global_dtors_aux_fini_array_entry[] +-__attribute__ ((__used__, section(".fini_array"), aligned(sizeof(void *)))) +- = { &__do_global_dtors_aux_alias }; +-#else /* defined(__FDPIC__) */ + static func_ptr __do_global_dtors_aux_fini_array_entry[] + __attribute__ ((__used__, section(".fini_array"), + aligned(__alignof__(func_ptr)))) = { __do_global_dtors_aux }; +-#endif /* defined(__FDPIC__) */ + #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */ + static void __attribute__((used)) + __do_global_dtors_aux_1 (void) +@@ -494,17 +486,9 @@ + #ifdef __LIBGCC_INIT_SECTION_ASM_OP__ + CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, frame_dummy) + #else /* defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ +-#if defined(__FDPIC__) +-__asm__("\t.equ\t__frame_dummy_alias, frame_dummy\n"); +-extern char __frame_dummy_alias; +-static void *__frame_dummy_init_array_entry[] +-__attribute__ ((__used__, section(".init_array"), aligned(sizeof(void *)))) +- = { &__frame_dummy_alias }; +-#else /* defined(__FDPIC__) */ + static func_ptr __frame_dummy_init_array_entry[] + __attribute__ ((__used__, section(".init_array"), + aligned(__alignof__(func_ptr)))) = { frame_dummy }; +-#endif /* defined(__FDPIC__) */ + #endif /* !defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ + #endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */ + diff --git a/patches/gcc-11.2.0/0007-fdpic-unwind.diff b/patches/gcc-11.2.0/0007-fdpic-unwind.diff new file mode 100644 index 0000000..61d3479 --- /dev/null +++ b/patches/gcc-11.2.0/0007-fdpic-unwind.diff @@ -0,0 +1,11 @@ +--- a/libgcc/unwind-pe.h 2024-03-14 05:59:53.754073149 +0900 ++++ b/libgcc/unwind-pe.h 2024-03-14 06:00:41.226074492 +0900 +@@ -262,7 +262,7 @@ + + if (result != 0) + { +-#if __FDPIC__ ++#if __FDPIC__ && __arm__ + /* FDPIC relative addresses imply taking the GOT address + into account. */ + if ((encoding & DW_EH_PE_pcrel) && (encoding & DW_EH_PE_indirect)) diff --git a/patches/gcc-11.2.0/0008-fdpic-crtstuff-pr114158.diff b/patches/gcc-11.2.0/0008-fdpic-crtstuff-pr114158.diff new file mode 100644 index 0000000..3986eed --- /dev/null +++ b/patches/gcc-11.2.0/0008-fdpic-crtstuff-pr114158.diff @@ -0,0 +1,38 @@ +--- a/libgcc/crtstuff.c 2023-05-29 17:46:32.000000000 +0900 ++++ b/libgcc/crtstuff.c 2024-03-14 06:03:42.398079615 +0900 +@@ -441,17 +441,9 @@ + #ifdef FINI_SECTION_ASM_OP + CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux) + #elif defined (FINI_ARRAY_SECTION_ASM_OP) +-#if defined(__FDPIC__) +-__asm__("\t.equ\t__do_global_dtors_aux_alias, __do_global_dtors_aux\n"); +-extern char __do_global_dtors_aux_alias; +-static void *__do_global_dtors_aux_fini_array_entry[] +-__attribute__ ((__used__, section(".fini_array"), aligned(sizeof(void *)))) +- = { &__do_global_dtors_aux_alias }; +-#else /* defined(__FDPIC__) */ + static func_ptr __do_global_dtors_aux_fini_array_entry[] + __attribute__ ((__used__, section(".fini_array"), + aligned(__alignof__(func_ptr)))) = { __do_global_dtors_aux }; +-#endif /* defined(__FDPIC__) */ + #else /* !FINI_SECTION_ASM_OP && !FINI_ARRAY_SECTION_ASM_OP */ + static void __attribute__((used)) + __do_global_dtors_aux_1 (void) +@@ -494,17 +486,9 @@ + #ifdef __LIBGCC_INIT_SECTION_ASM_OP__ + CRT_CALL_STATIC_FUNCTION (__LIBGCC_INIT_SECTION_ASM_OP__, frame_dummy) + #else /* defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ +-#if defined(__FDPIC__) +-__asm__("\t.equ\t__frame_dummy_alias, frame_dummy\n"); +-extern char __frame_dummy_alias; +-static void *__frame_dummy_init_array_entry[] +-__attribute__ ((__used__, section(".init_array"), aligned(sizeof(void *)))) +- = { &__frame_dummy_alias }; +-#else /* defined(__FDPIC__) */ + static func_ptr __frame_dummy_init_array_entry[] + __attribute__ ((__used__, section(".init_array"), + aligned(__alignof__(func_ptr)))) = { frame_dummy }; +-#endif /* defined(__FDPIC__) */ + #endif /* !defined(__LIBGCC_INIT_SECTION_ASM_OP__) */ + #endif /* USE_EH_FRAME_REGISTRY || USE_TM_CLONE_REGISTRY */ +