public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Giuliano Belinassi <giulianob@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/giulianob/heads/pfe_backport_clean)] Backport varasm: Fix up __patchable_function_entries handling Date: Thu, 21 Oct 2021 14:49:25 +0000 (GMT) [thread overview] Message-ID: <20211021144925.1627D3857C52@sourceware.org> (raw) https://gcc.gnu.org/g:bb8b3f4aee3c81ccd4d884846a4d87f543c6b75b commit bb8b3f4aee3c81ccd4d884846a4d87f543c6b75b Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Dec 16 16:15:35 2020 +0100 Backport varasm: Fix up __patchable_function_entries handling The SECTION_LINK_ORDER changes don't seem to work properly. If I compile: static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((patchable_function_entry(0, 0))) int foo (int x) { return x + 1; } static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((patchable_function_entry(0, 0))) int bar (int x) { return x + 2; } int baz (int x) { return foo (x) + 1; } int qux (int x) { return bar (x) + 2; } (distilled from aarch64 Linux kernel) with -O2 -fpatchable-function-entry=2 on aarch64 compiler configured against latest binutils, I get: ... .section __patchable_function_entries,"awo",@progbits,baz ... .section __patchable_function_entries ... in the assembly, but when it is assembled, one gets: [ 4] __patchable_function_entries PROGBITS 0000000000000000 000060 000008 00 WAL 1 0 8 [ 5] .rela__patchable_function_entries RELA 0000000000000000 000280 000018 18 I 12 4 8 [ 6] __patchable_function_entries PROGBITS 0000000000000000 000068 000008 00 0 0 8 [ 7] .rela__patchable_function_entries RELA 0000000000000000 000298 000018 18 I 12 6 8 i.e. one writable allocated section with SHF_LINK_ORDER and another non-allocated non-writable without link order. In the kernel case there is always one entry in the WAL section and then dozens or more in the non-allocated one. The kernel then fails to link: WARNING: modpost: vmlinux.o (__patchable_function_entries): unexpected non-allocatable section. Did you forget to use "ax"/"aw" in a .S file? Note that for example <linux/init.h> contains section definitions for use in .S files. ld: .init.data has both ordered [`__patchable_function_entries' in init/main.o] and unordered [`.init.data' in +./drivers/firmware/efi/libstub/vsprintf.stub.o] sections ld: final link failed: bad value make: *** [Makefile:1175: vmlinux] Error 1 The following patch fixes it by always forcing full section flags for SECTION_LINK_ORDER sections. 2020-12-16 Jakub Jelinek <jakub@redhat.com> * varasm.c (default_elf_asm_named_section): Always force section flags even for sections with SECTION_LINK_ORDER flag. Diff: --- gcc/varasm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index 7b0792ddaed..9e0e7c0976f 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6363,9 +6363,10 @@ default_elf_asm_named_section (const char *name, unsigned int flags, /* If we have already declared this section, we can use an abbreviated form to switch back to it -- unless this section is - part of a COMDAT groups, in which case GAS requires the full - declaration every time. */ + part of a COMDAT groups or with SHF_GNU_RETAIN or with SHF_LINK_ORDER, + in which case GAS requires the full declaration every time. */ if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + && !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER)) && (flags & SECTION_DECLARED)) { fprintf (asm_out_file, "\t.section\t%s\n", name);
next reply other threads:[~2021-10-21 14:49 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-21 14:49 Giuliano Belinassi [this message] -- strict thread matches above, loose matches on Subject: below -- 2021-10-19 18:40 Giuliano Belinassi 2021-10-19 18:13 Giuliano Belinassi
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211021144925.1627D3857C52@sourceware.org \ --to=giulianob@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).