yasm/yasm-Update-elf-objfmt.c.patch
Martin Pluskal eaab39c3c9 Accepting request 1033712 from home:lwfinger:branches:devel:tools:compiler
- Modify yasm to support .note.gnu.property note section
  This feature is needed to build VirtualBox-7.0.x.
  Patch from https://src.fedoraproject.org/rpms/yasm/pull-request/1#_2.
  File "yasm-Update-elf-objfmt.c.patch" added.

OBS-URL: https://build.opensuse.org/request/show/1033712
OBS-URL: https://build.opensuse.org/package/show/devel:tools:compiler/yasm?expand=0&rev=33
2022-11-07 08:32:40 +00:00

30 lines
1.4 KiB
Diff

From: kalebskeithley <kaleb@redhat.com>
Date: Thu, 21 May 2020 09:12:36 -0400
Subject: [PATCH] Update elf-objfmt.c
tl;dnr: add support for note.gnu.property note sections.
ceph has a few optimized crc32 routines hand written in assembly in yasm format. (Nobody appears to have the stomach for rewriting them in another format.) Fedora requires that libraries be CET enabled. IOW all .o comprising a shared library need a note.gnu.properties NOTE section with some magic bits that tell the linker that the .o was compiled with the appropriate options.
I can add such a note section, but without this change yasm will not set the correct section flag and I have to resort to some dd magic to set the correct section type before linking all the .o files into the shlib.
---
modules/objfmts/elf/elf-objfmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/objfmts/elf/elf-objfmt.c b/modules/objfmts/elf/elf-objfmt.c
index 0c3a1426..c4360c03 100644
--- a/modules/objfmts/elf/elf-objfmt.c
+++ b/modules/objfmts/elf/elf-objfmt.c
@@ -1077,6 +1077,10 @@ elf_objfmt_section_switch(yasm_object *object, yasm_valparamhead *valparams,
align = 0;
data.type = SHT_PROGBITS;
data.flags = 0;
+ } else if (strcmp(sectname, ".note.gnu.property") == 0) {
+ align = 8;
+ data.type = SHT_NOTE;
+ data.flags = 0;
} else {
/* Default to code */
align = 1;