All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2 1/5] binutils: Package libdep linker plugins
@ 2021-02-03  1:36 Khem Raj
  2021-02-03  1:36 ` [v2 2/5] binutils: Disable parallel install for target/nativesdk binutils Khem Raj
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Khem Raj @ 2021-02-03  1:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

this is new plugin added in binutils 2.36

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/binutils/binutils.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meta/recipes-devtools/binutils/binutils.inc b/meta/recipes-devtools/binutils/binutils.inc
index e93cd50b20..81891963c8 100644
--- a/meta/recipes-devtools/binutils/binutils.inc
+++ b/meta/recipes-devtools/binutils/binutils.inc
@@ -18,6 +18,7 @@ inherit autotools gettext multilib_header texinfo
 FILES_${PN} = " \
 	${bindir}/${TARGET_PREFIX}* \
 	${libdir}/lib*.so.* \
+	${libdir}/bfd-plugins/lib*.so \
 	${libdir}/lib*-${PV}*.so \
 	${prefix}/${TARGET_SYS}/bin/* \
         ${bindir}/embedspu"
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [v2 2/5] binutils: Disable parallel install for target/nativesdk binutils
  2021-02-03  1:36 [v2 1/5] binutils: Package libdep linker plugins Khem Raj
@ 2021-02-03  1:36 ` Khem Raj
  2021-02-03  1:36 ` [v2 3/5] glibc: Drop adding .file directive in asm files Khem Raj
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2021-02-03  1:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

2.36 has a build race between libctf and libbfd

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/binutils/binutils_2.36.bb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-devtools/binutils/binutils_2.36.bb b/meta/recipes-devtools/binutils/binutils_2.36.bb
index 976e49765a..f316eb8d1c 100644
--- a/meta/recipes-devtools/binutils/binutils_2.36.bb
+++ b/meta/recipes-devtools/binutils/binutils_2.36.bb
@@ -52,6 +52,10 @@ do_install_class-native () {
 	rmdir ${D}/${libdir}64 || :
 }
 
+# libctf races with libbfd
+PARALLEL_MAKEINST_class-target = ""
+PARALLEL_MAKEINST_class-nativesdk = ""
+
 # Split out libbfd-*.so and libopcodes-*.so so including perf doesn't include
 # extra stuff
 PACKAGE_BEFORE_PN += "libbfd libopcodes"
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [v2 3/5] glibc: Drop adding .file directive in asm files
  2021-02-03  1:36 [v2 1/5] binutils: Package libdep linker plugins Khem Raj
  2021-02-03  1:36 ` [v2 2/5] binutils: Disable parallel install for target/nativesdk binutils Khem Raj
@ 2021-02-03  1:36 ` Khem Raj
  2021-02-03  1:36 ` [v2 4/5] musl: " Khem Raj
  2021-02-03  1:36 ` [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade Khem Raj
  3 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2021-02-03  1:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

it was a workaround for binutils issue which is fixed in 2.36 with

https://sourceware.org/bugzilla/show_bug.cgi?id=26822

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...0026-inject-file-assembly-directives.patch | 244 ------------------
 meta/recipes-core/glibc/glibc_2.33.bb         |   1 -
 2 files changed, 245 deletions(-)
 delete mode 100644 meta/recipes-core/glibc/glibc/0026-inject-file-assembly-directives.patch

diff --git a/meta/recipes-core/glibc/glibc/0026-inject-file-assembly-directives.patch b/meta/recipes-core/glibc/glibc/0026-inject-file-assembly-directives.patch
deleted file mode 100644
index 5137fedb7b..0000000000
--- a/meta/recipes-core/glibc/glibc/0026-inject-file-assembly-directives.patch
+++ /dev/null
@@ -1,244 +0,0 @@
-From cf043d56638883157dbfaa8c6a8e2f63a6f66280 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Thu, 29 Nov 2018 17:29:35 -0800
-Subject: [PATCH 26/29] inject file assembly directives
-
-Currently, non-IA builds are not reproducibile since build paths are
-being injected into the debug symbols. These are coming from the use of
-.S assembler files during the glibc build. No STT_FILE section is added
-during the assembly but when linking, ld decides to add one to aid
-debugging and ensure references between the different object files its
-linking remain clear.
-
-We can avoid this by injecting a file header into the assembler files
-ahead of time, choosing a filename which does not contain build system
-paths.
-
-This is a bit of a workaround/hack but does significantly reduce the
-build system references in target binaries for the non-IA architectures
-which use .S files.
-
-RP
-2018/10/3
-
-fixed in binutils 2.36 [1]
-
-[1] https://sourceware.org/bugzilla/show_bug.cgi?id=26822
-
-Upstream-Status: OE-Specific [ Drop when upgrading binutils 2.36+ ]
-
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- csu/abi-note.c                                | 2 ++
- sysdeps/aarch64/crti.S                        | 2 ++
- sysdeps/aarch64/crtn.S                        | 1 +
- sysdeps/aarch64/dl-tlsdesc.S                  | 2 ++
- sysdeps/aarch64/dl-trampoline.S               | 2 ++
- sysdeps/aarch64/start.S                       | 2 ++
- sysdeps/arm/crti.S                            | 2 ++
- sysdeps/arm/crtn.S                            | 2 ++
- sysdeps/arm/dl-tlsdesc.S                      | 2 ++
- sysdeps/arm/dl-trampoline.S                   | 2 ++
- sysdeps/arm/start.S                           | 2 ++
- sysdeps/mips/start.S                          | 2 ++
- sysdeps/powerpc/powerpc32/dl-start.S          | 2 ++
- sysdeps/powerpc/powerpc32/start.S             | 2 ++
- sysdeps/powerpc/powerpc64/start.S             | 2 ++
- sysdeps/unix/sysv/linux/aarch64/__read_tp.S   | 2 ++
- sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S   | 2 ++
- sysdeps/unix/sysv/linux/arm/libc-do-syscall.S | 2 ++
- sysdeps/unix/sysv/linux/powerpc/dl-brk.S      | 2 ++
- 19 files changed, 37 insertions(+)
-
---- a/sysdeps/aarch64/crti.S
-+++ b/sysdeps/aarch64/crti.S
-@@ -50,6 +50,8 @@
- # define PREINIT_FUNCTION_WEAK 1
- #endif
- 
-+    .file "crti.S"
-+
- #if PREINIT_FUNCTION_WEAK
- 	weak_extern (PREINIT_FUNCTION)
- #else
---- a/sysdeps/aarch64/crtn.S
-+++ b/sysdeps/aarch64/crtn.S
-@@ -38,6 +38,7 @@
-    corresponding to the prologues in crti.S. */
- 
- #include <sysdep.h>
-+	.file "crtn.S"
- 
- 	.section .init,"ax",%progbits
- 	ldp	x29, x30, [sp], 16
---- a/sysdeps/aarch64/dl-tlsdesc.S
-+++ b/sysdeps/aarch64/dl-tlsdesc.S
-@@ -22,6 +22,8 @@
- #include <tls.h>
- #include "tlsdesc.h"
- 
-+	.file "dl-tlsdesc.S"
-+
- #define NSAVEDQREGPAIRS	16
- #define SAVE_Q_REGISTERS				\
- 	stp	q0, q1,	[sp, #-32*NSAVEDQREGPAIRS]!;	\
---- a/sysdeps/aarch64/dl-trampoline.S
-+++ b/sysdeps/aarch64/dl-trampoline.S
-@@ -21,6 +21,8 @@
- 
- #include "dl-link.h"
- 
-+	.file "dl-trampoline.S"
-+
- #define ip0 x16
- #define ip0l PTR_REG (16)
- #define ip1 x17
---- a/sysdeps/aarch64/start.S
-+++ b/sysdeps/aarch64/start.S
-@@ -18,6 +18,8 @@
- 
- #include <sysdep.h>
- 
-+	.file "start.S"
-+
- /* This is the canonical entry point, usually the first thing in the text
-    segment.
- 
---- a/sysdeps/arm/crti.S
-+++ b/sysdeps/arm/crti.S
-@@ -57,6 +57,8 @@
- 	.hidden PREINIT_FUNCTION
- #endif
- 
-+    .file "crti.S"
-+
- #if PREINIT_FUNCTION_WEAK
- 	.p2align 2
- 	.type call_weak_fn, %function
---- a/sysdeps/arm/crtn.S
-+++ b/sysdeps/arm/crtn.S
-@@ -37,6 +37,8 @@
- #define NO_THUMB
- #include <sysdep.h>
- 
-+    .file "crtn.S"
-+
- /* crtn.S puts function epilogues in the .init and .fini sections
-    corresponding to the prologues in crti.S. */
- 
---- a/sysdeps/arm/dl-tlsdesc.S
-+++ b/sysdeps/arm/dl-tlsdesc.S
-@@ -21,6 +21,8 @@
- #include <tls.h>
- #include "tlsdesc.h"
- 
-+	.file "dl-tlsdesc.S"
-+
- 	.text
- 	@ emit debug information with cfi
- 	@ use arm-specific pseudos for unwinding itself
---- a/sysdeps/arm/dl-trampoline.S
-+++ b/sysdeps/arm/dl-trampoline.S
-@@ -21,6 +21,8 @@
- #include <sysdep.h>
- #include <libc-symbols.h>
- 
-+	.file "dl-trampoline.S"
-+
- 	.text
- 	.globl _dl_runtime_resolve
- 	.type _dl_runtime_resolve, #function
---- a/sysdeps/arm/start.S
-+++ b/sysdeps/arm/start.S
-@@ -57,6 +57,8 @@
- 					NULL
- */
- 
-+	.file "start.S"
-+
- /* Tag_ABI_align8_preserved: This code preserves 8-byte
-    alignment in any callee.  */
- 	.eabi_attribute 25, 1
---- a/sysdeps/mips/start.S
-+++ b/sysdeps/mips/start.S
-@@ -38,6 +38,8 @@
- #include <sgidefs.h>
- #include <sys/asm.h>
- 
-+	.file "start.S"
-+
- #ifndef ENTRY_POINT
- #error ENTRY_POINT needs to be defined for start.S on MIPS/ELF.
- #endif
---- a/sysdeps/powerpc/powerpc32/dl-start.S
-+++ b/sysdeps/powerpc/powerpc32/dl-start.S
-@@ -18,6 +18,8 @@
- 
- #include <sysdep.h>
- 
-+	.file "dl-start.S"
-+
- /* Initial entry point code for the dynamic linker.
-    The C function `_dl_start' is the real entry point;
-    its return value is the user program's entry point.	*/
---- a/sysdeps/powerpc/powerpc32/start.S
-+++ b/sysdeps/powerpc/powerpc32/start.S
-@@ -35,6 +35,8 @@
- 
- #include <sysdep.h>
- 
-+	.file "start.S"
-+
- /* We do not want .eh_frame info for crt1.o since crt1.o is linked
-    before crtbegin.o, the file defining __EH_FRAME_BEGIN__.  */
- #undef cfi_startproc
---- a/sysdeps/powerpc/powerpc64/start.S
-+++ b/sysdeps/powerpc/powerpc64/start.S
-@@ -35,6 +35,8 @@
- 
- #include <sysdep.h>
- 
-+	.file "start.S"
-+
- /* We do not want .eh_frame info for crt1.o since crt1.o is linked
-    before crtbegin.o, the file defining __EH_FRAME_BEGIN__.  */
- #undef cfi_startproc
---- a/sysdeps/unix/sysv/linux/aarch64/__read_tp.S
-+++ b/sysdeps/unix/sysv/linux/aarch64/__read_tp.S
-@@ -18,6 +18,8 @@
- 
- #include <sysdep.h>
- 
-+	.file "__read_tp.S"
-+
- 	.hidden __read_tp
- ENTRY (__read_tp)
- 	mrs	x0, tpidr_el0
---- a/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
-+++ b/sysdeps/unix/sysv/linux/arm/aeabi_read_tp.S
-@@ -39,6 +39,8 @@
-    a normal function call) in a high page of memory; tail call to the
-    helper.  */
- 
-+	.file "aeabi_read_tp.S"
-+
- 	.hidden __aeabi_read_tp
- ENTRY (__aeabi_read_tp)
- #ifdef ARCH_HAS_HARD_TP
---- a/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S
-+++ b/sysdeps/unix/sysv/linux/arm/libc-do-syscall.S
-@@ -27,6 +27,8 @@
-    ARM unwind tables for register to register moves, the actual opcodes
-    are not defined.  */
- 
-+      .file "libc-do-syscall.S"
-+
- #if defined(__thumb__)
- 	.thumb
- 	.syntax unified
---- a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S
-+++ b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S
-@@ -1 +1,3 @@
-+	.file "dl-brk.S"
-+
- #include <brk.S>
diff --git a/meta/recipes-core/glibc/glibc_2.33.bb b/meta/recipes-core/glibc/glibc_2.33.bb
index 2a0e464385..2259d60196 100644
--- a/meta/recipes-core/glibc/glibc_2.33.bb
+++ b/meta/recipes-core/glibc/glibc_2.33.bb
@@ -38,7 +38,6 @@ SRC_URI =  "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://0023-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \
            file://0024-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \
            file://0025-intl-Emit-no-lines-in-bison-generated-files.patch \
-           file://0026-inject-file-assembly-directives.patch \
            file://0027-locale-prevent-maybe-uninitialized-errors-with-Os-BZ.patch \
            file://0028-readlib-Add-OECORE_KNOWN_INTERPRETER_NAMES-to-known-.patch \
            file://0029-wordsize.h-Unify-the-header-between-arm-and-aarch64.patch \
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [v2 4/5] musl: Drop adding .file directive in asm files
  2021-02-03  1:36 [v2 1/5] binutils: Package libdep linker plugins Khem Raj
  2021-02-03  1:36 ` [v2 2/5] binutils: Disable parallel install for target/nativesdk binutils Khem Raj
  2021-02-03  1:36 ` [v2 3/5] glibc: Drop adding .file directive in asm files Khem Raj
@ 2021-02-03  1:36 ` Khem Raj
  2021-02-03  1:36 ` [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade Khem Raj
  3 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2021-02-03  1:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

it was a workaround for binutils issue which is fixed in 2.36 with

https://sourceware.org/bugzilla/show_bug.cgi?id=26822

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../musl/0001-crt-Add-.file-directive.patch   | 245 ------------------
 meta/recipes-core/musl/musl_git.bb            |   1 -
 2 files changed, 246 deletions(-)
 delete mode 100644 meta/recipes-core/musl/musl/0001-crt-Add-.file-directive.patch

diff --git a/meta/recipes-core/musl/musl/0001-crt-Add-.file-directive.patch b/meta/recipes-core/musl/musl/0001-crt-Add-.file-directive.patch
deleted file mode 100644
index 1cd08cdcd4..0000000000
--- a/meta/recipes-core/musl/musl/0001-crt-Add-.file-directive.patch
+++ /dev/null
@@ -1,245 +0,0 @@
-From b0124f3c4f2a353506621d387135ebea6b8c6609 Mon Sep 17 00:00:00 2001
-From: Khem Raj <raj.khem@gmail.com>
-Date: Thu, 29 Oct 2020 22:40:53 -0700
-Subject: [PATCH] crt: Add .file directive
-
-Musl linked binaries come out to be not reproducible because
-absolute build path is seen in debug info of crti.o and crtn.o
-This is due to the fact that these objects are built from assembly
-source files and they are missing .file directive
-if we add .file <filename>.s in them then debug info encodes this
-value instead of absolute path in debug_line section
-
-fixed in binutils 2.36 [1]
-
-[1] https://sourceware.org/bugzilla/show_bug.cgi?id=26822
-
-Upstream-Status: OE-Specific [ Drop when upgrading binutils 2.36+ ]
-Signed-off-by: Khem Raj <raj.khem@gmail.com>
----
- crt/aarch64/crti.s    | 1 +
- crt/aarch64/crtn.s    | 1 +
- crt/arm/crti.s        | 1 +
- crt/arm/crtn.s        | 1 +
- crt/i386/crti.s       | 1 +
- crt/i386/crtn.s       | 1 +
- crt/microblaze/crti.s | 1 +
- crt/microblaze/crtn.s | 1 +
- crt/mips/crti.s       | 1 +
- crt/mips/crtn.s       | 1 +
- crt/mips64/crti.s     | 1 +
- crt/mips64/crtn.s     | 1 +
- crt/mipsn32/crti.s    | 1 +
- crt/mipsn32/crtn.s    | 1 +
- crt/or1k/crti.s       | 1 +
- crt/or1k/crtn.s       | 1 +
- crt/powerpc/crti.s    | 1 +
- crt/powerpc/crtn.s    | 1 +
- crt/powerpc64/crti.s  | 1 +
- crt/powerpc64/crtn.s  | 1 +
- crt/s390x/crti.s      | 1 +
- crt/s390x/crtn.s      | 1 +
- crt/sh/crti.s         | 1 +
- crt/sh/crtn.s         | 1 +
- crt/x32/crti.s        | 1 +
- crt/x32/crtn.s        | 1 +
- crt/x86_64/crti.s     | 1 +
- crt/x86_64/crtn.s     | 1 +
- 28 files changed, 28 insertions(+)
-
---- a/crt/aarch64/crti.s
-+++ b/crt/aarch64/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- .type _init,%function
---- a/crt/aarch64/crtn.s
-+++ b/crt/aarch64/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	ldp x29,x30,[sp],#16
- 	ret
---- a/crt/arm/crti.s
-+++ b/crt/arm/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .syntax unified
- 
- .section .init
---- a/crt/arm/crtn.s
-+++ b/crt/arm/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .syntax unified
- 
- .section .init
---- a/crt/i386/crti.s
-+++ b/crt/i386/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- _init:
---- a/crt/i386/crtn.s
-+++ b/crt/i386/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	add $12,%esp
- 	ret
---- a/crt/microblaze/crti.s
-+++ b/crt/microblaze/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- .align 2
---- a/crt/microblaze/crtn.s
-+++ b/crt/microblaze/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	lwi r15, r1, 0
- 	rtsd r15, 8
---- a/crt/mips/crti.s
-+++ b/crt/mips/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .set noreorder
- 
- .section .init
---- a/crt/mips/crtn.s
-+++ b/crt/mips/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .set noreorder
- 
- .section .init
---- a/crt/mips64/crti.s
-+++ b/crt/mips64/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .set noreorder
- 
- .section .init
---- a/crt/mips64/crtn.s
-+++ b/crt/mips64/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .set noreorder
- 
- .section .init
---- a/crt/mipsn32/crti.s
-+++ b/crt/mipsn32/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .set	noreorder
- .section	.init
- .global	_init
---- a/crt/mipsn32/crtn.s
-+++ b/crt/mipsn32/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .set	noreorder
- .section	.init
- 	ld	$gp, 16($sp)
---- a/crt/or1k/crti.s
-+++ b/crt/or1k/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- _init:
---- a/crt/or1k/crtn.s
-+++ b/crt/or1k/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	l.lwz	r9,0(r1)
- 	l.jr	r9
---- a/crt/powerpc/crti.s
-+++ b/crt/powerpc/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .align 2
- .global _init
---- a/crt/powerpc/crtn.s
-+++ b/crt/powerpc/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- .align 2
- 	lwz 0,36(1)
---- a/crt/powerpc64/crti.s
-+++ b/crt/powerpc64/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .align 2
- .global _init
---- a/crt/powerpc64/crtn.s
-+++ b/crt/powerpc64/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- .align 2
- 	addi 1, 1, 32
---- a/crt/s390x/crti.s
-+++ b/crt/s390x/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .align 2
- .global _init
---- a/crt/s390x/crtn.s
-+++ b/crt/s390x/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- .align 2
- 	lmg  %r14, %r15, 272(%r15)
---- a/crt/sh/crti.s
-+++ b/crt/sh/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global  _init
- .type    _init, @function
---- a/crt/sh/crtn.s
-+++ b/crt/sh/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	lds.l @r15+, pr
- 	mov.l @r15+, r14
---- a/crt/x32/crti.s
-+++ b/crt/x32/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- _init:
---- a/crt/x32/crtn.s
-+++ b/crt/x32/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	pop %rax
- 	ret
---- a/crt/x86_64/crti.s
-+++ b/crt/x86_64/crti.s
-@@ -1,3 +1,4 @@
-+.file "crti.s"
- .section .init
- .global _init
- _init:
---- a/crt/x86_64/crtn.s
-+++ b/crt/x86_64/crtn.s
-@@ -1,3 +1,4 @@
-+.file "crtn.s"
- .section .init
- 	pop %rax
- 	ret
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index 265f79f2fd..249ce53521 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -15,7 +15,6 @@ PV = "${BASEVER}+git${SRCPV}"
 SRC_URI = "git://git.musl-libc.org/musl \
            file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
            file://0002-ldso-Use-syslibdir-and-libdir-as-default-pathes-to-l.patch \
-           file://0001-crt-Add-.file-directive.patch \
           "
 
 S = "${WORKDIR}/git"
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  1:36 [v2 1/5] binutils: Package libdep linker plugins Khem Raj
                   ` (2 preceding siblings ...)
  2021-02-03  1:36 ` [v2 4/5] musl: " Khem Raj
@ 2021-02-03  1:36 ` Khem Raj
  2021-02-03  3:12   ` [OE-core] " Bruce Ashfield
  3 siblings, 1 reply; 11+ messages in thread
From: Khem Raj @ 2021-02-03  1:36 UTC (permalink / raw)
  To: openembedded-core; +Cc: Khem Raj

This is for master-next testing only !!

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
 ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
 meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
 3 files changed, 280 insertions(+)
 create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
 create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch

diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
new file mode 100644
index 0000000000..f606e3ee6d
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
@@ -0,0 +1,150 @@
+From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Date: Mon, 14 Dec 2020 16:04:20 -0600
+Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
+
+The Clang assembler likes to strip section symbols, which means objtool
+can't reference some text code by its section.  This confuses objtool
+greatly, causing it to seg fault.
+
+The fix is similar to what was done before, for ORC reloc generation:
+
+  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
+
+Factor out that code into a common helper and use it for static call
+reloc generation as well.
+
+Reported-by: Arnd Bergmann <arnd@kernel.org>
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Reviewed-by: Miroslav Benes <mbenes@suse.cz>
+Link: https://github.com/ClangBuiltLinux/linux/issues/1207
+Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
+---
+ tools/objtool/check.c   | 11 +++++++++--
+ tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
+ tools/objtool/elf.h     |  2 ++
+ tools/objtool/orc_gen.c | 29 +++++------------------------
+ 4 files changed, 42 insertions(+), 26 deletions(-)
+
+diff --git a/tools/objtool/check.c b/tools/objtool/check.c
+index c6ab44543c92..5f8d3eed78a1 100644
+--- a/tools/objtool/check.c
++++ b/tools/objtool/check.c
+@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
+ 
+ 		/* populate reloc for 'addr' */
+ 		reloc = malloc(sizeof(*reloc));
++
+ 		if (!reloc) {
+ 			perror("malloc");
+ 			return -1;
+ 		}
+ 		memset(reloc, 0, sizeof(*reloc));
+-		reloc->sym = insn->sec->sym;
+-		reloc->addend = insn->offset;
++
++		insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
++		if (!reloc->sym) {
++			WARN_FUNC("static call tramp: missing containing symbol",
++				  insn->sec, insn->offset);
++			return -1;
++		}
++
+ 		reloc->type = R_X86_64_PC32;
+ 		reloc->offset = idx * sizeof(struct static_call_site);
+ 		reloc->sec = reloc_sec;
+diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
+index 4e1d7460574b..be89c741ba9a 100644
+--- a/tools/objtool/elf.c
++++ b/tools/objtool/elf.c
+@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
+ 	return find_reloc_by_dest_range(elf, sec, offset, 1);
+ }
+ 
++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
++			      struct reloc *reloc)
++{
++	if (sec->sym) {
++		reloc->sym = sec->sym;
++		reloc->addend = offset;
++		return;
++	}
++
++	/*
++	 * The Clang assembler strips section symbols, so we have to reference
++	 * the function symbol instead:
++	 */
++	reloc->sym = find_symbol_containing(sec, offset);
++	if (!reloc->sym) {
++		/*
++		 * Hack alert.  This happens when we need to reference the NOP
++		 * pad insn immediately after the function.
++		 */
++		reloc->sym = find_symbol_containing(sec, offset - 1);
++	}
++
++	if (reloc->sym)
++		reloc->addend = offset - reloc->sym->offset;
++}
++
+ static int read_sections(struct elf *elf)
+ {
+ 	Elf_Scn *s = NULL;
+diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
+index 807f8c670097..e6890cc70a25 100644
+--- a/tools/objtool/elf.h
++++ b/tools/objtool/elf.h
+@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
+ struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
+ 				     unsigned long offset, unsigned int len);
+ struct symbol *find_func_containing(struct section *sec, unsigned long offset);
++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
++			      struct reloc *reloc);
+ int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
+ 
+ #define for_each_sec(file, sec)						\
+diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
+index 235663b96adc..9ce68b385a1b 100644
+--- a/tools/objtool/orc_gen.c
++++ b/tools/objtool/orc_gen.c
+@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
+ 	}
+ 	memset(reloc, 0, sizeof(*reloc));
+ 
+-	if (insn_sec->sym) {
+-		reloc->sym = insn_sec->sym;
+-		reloc->addend = insn_off;
+-	} else {
+-		/*
+-		 * The Clang assembler doesn't produce section symbols, so we
+-		 * have to reference the function symbol instead:
+-		 */
+-		reloc->sym = find_symbol_containing(insn_sec, insn_off);
+-		if (!reloc->sym) {
+-			/*
+-			 * Hack alert.  This happens when we need to reference
+-			 * the NOP pad insn immediately after the function.
+-			 */
+-			reloc->sym = find_symbol_containing(insn_sec,
+-							   insn_off - 1);
+-		}
+-		if (!reloc->sym) {
+-			WARN("missing symbol for insn at offset 0x%lx\n",
+-			     insn_off);
+-			return -1;
+-		}
+-
+-		reloc->addend = insn_off - reloc->sym->offset;
++	insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
++	if (!reloc->sym) {
++		WARN("missing symbol for insn at offset 0x%lx",
++		     insn_off);
++		return -1;
+ 	}
+ 
+ 	reloc->type = R_X86_64_PC32;
+-- 
+2.30.0
+
diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
new file mode 100644
index 0000000000..320d7e929c
--- /dev/null
+++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
@@ -0,0 +1,125 @@
+From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
+From: Nick Desaulniers <ndesaulniers@google.com>
+Date: Tue, 12 Jan 2021 11:46:24 -0800
+Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
+
+Arnd found a randconfig that produces the warning:
+
+  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
+  offset 0x3e
+
+when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
+notes:
+
+  With the LLVM assembler not generating section symbols, objtool has no
+  way to reference this code when it generates ORC unwinder entries,
+  because this code is outside of any ELF function.
+
+  The limitation now being imposed by objtool is that all code must be
+  contained in an ELF symbol.  And .L symbols don't create such symbols.
+
+  So basically, you can use an .L symbol *inside* a function or a code
+  segment, you just can't use the .L symbol to contain the code using a
+  SYM_*_START/END annotation pair.
+
+Fangrui notes that this optimization is helpful for reducing image size
+when compiling with -ffunction-sections and -fdata-sections. I have
+observed on the order of tens of thousands of symbols for the kernel
+images built with those flags.
+
+A patch has been authored against GNU binutils to match this behavior
+of not generating unused section symbols ([1]), so this will
+also become a problem for users of GNU binutils once they upgrade to 2.36.
+
+Omit the .L prefix on a label so that the assembler will emit an entry
+into the symbol table for the label, with STB_LOCAL binding. This
+enables objtool to generate proper unwind info here with LLVM_IAS=1 or
+GNU binutils 2.36+.
+
+ [ bp: Massage commit message. ]
+
+Reported-by: Arnd Bergmann <arnd@arndb.de>
+Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Suggested-by: Borislav Petkov <bp@alien8.de>
+Suggested-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
+Link: https://github.com/ClangBuiltLinux/linux/issues/1209
+Link: https://reviews.llvm.org/D93783
+Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
+Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
+---
+ Documentation/asm-annotations.rst | 5 +++++
+ arch/x86/entry/thunk_64.S         | 8 ++++----
+ include/linux/linkage.h           | 5 +++++
+ 3 files changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
+index 32ea57483378..76424e0431f4 100644
+--- a/Documentation/asm-annotations.rst
++++ b/Documentation/asm-annotations.rst
+@@ -100,6 +100,11 @@ Instruction Macros
+ ~~~~~~~~~~~~~~~~~~
+ This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
+ 
++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
++prefixed symbols can be used within a code region, but should be avoided for
++denoting a range of code via ``SYM_*_START/END`` annotations.
++
+ * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
+   most frequent markings**. They are used for functions with standard calling
+   conventions -- global and local. Like in C, they both align the functions to
+diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
+index ccd32877a3c4..c9a9fbf1655f 100644
+--- a/arch/x86/entry/thunk_64.S
++++ b/arch/x86/entry/thunk_64.S
+@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
+ 	.endif
+ 
+ 	call \func
+-	jmp  .L_restore
++	jmp  __thunk_restore
+ SYM_FUNC_END(\name)
+ 	_ASM_NOKPROBE(\name)
+ 	.endm
+@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
+ #endif
+ 
+ #ifdef CONFIG_PREEMPTION
+-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
+ 	popq %r11
+ 	popq %r10
+ 	popq %r9
+@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
+ 	popq %rdi
+ 	popq %rbp
+ 	ret
+-	_ASM_NOKPROBE(.L_restore)
+-SYM_CODE_END(.L_restore)
++	_ASM_NOKPROBE(__thunk_restore)
++SYM_CODE_END(__thunk_restore)
+ #endif
+diff --git a/include/linux/linkage.h b/include/linux/linkage.h
+index 5bcfbd972e97..dbf8506decca 100644
+--- a/include/linux/linkage.h
++++ b/include/linux/linkage.h
+@@ -178,6 +178,11 @@
+  * Objtool generates debug info for both FUNC & CODE, but needs special
+  * annotations for each CODE's start (to describe the actual stack frame).
+  *
++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
++ * names that have a  .L prefix do not emit symbol table entries. .L
++ * prefixed symbols can be used within a code region, but should be avoided for
++ * denoting a range of code via ``SYM_*_START/END`` annotations.
++ *
+  * ALIAS -- does not generate debug info -- the aliased function will
+  */
+ 
+-- 
+2.30.0
+
diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
index 7e570b04f5..aa328aff52 100644
--- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
+++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
@@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
 SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
            git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
 
+SRC_URI += "\
+            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
+            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
+"
+
 LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
 LINUX_VERSION ?= "5.10.5"
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  1:36 ` [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade Khem Raj
@ 2021-02-03  3:12   ` Bruce Ashfield
  2021-02-03  3:18     ` Khem Raj
  0 siblings, 1 reply; 11+ messages in thread
From: Bruce Ashfield @ 2021-02-03  3:12 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

Richard,

Obviously ignore this patch.

It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
it's a hassle to have to wonder if this has been applied, have a
failure, sent a revert, etc.

I'm not even sure why it was sent.

Bruce

On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> This is for master-next testing only !!
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
>  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
>  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
>  3 files changed, 280 insertions(+)
>  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
>  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
>
> diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> new file mode 100644
> index 0000000000..f606e3ee6d
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> @@ -0,0 +1,150 @@
> +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> +From: Josh Poimboeuf <jpoimboe@redhat.com>
> +Date: Mon, 14 Dec 2020 16:04:20 -0600
> +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> +
> +The Clang assembler likes to strip section symbols, which means objtool
> +can't reference some text code by its section.  This confuses objtool
> +greatly, causing it to seg fault.
> +
> +The fix is similar to what was done before, for ORC reloc generation:
> +
> +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> +
> +Factor out that code into a common helper and use it for static call
> +reloc generation as well.
> +
> +Reported-by: Arnd Bergmann <arnd@kernel.org>
> +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> +---
> + tools/objtool/check.c   | 11 +++++++++--
> + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> + tools/objtool/elf.h     |  2 ++
> + tools/objtool/orc_gen.c | 29 +++++------------------------
> + 4 files changed, 42 insertions(+), 26 deletions(-)
> +
> +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> +index c6ab44543c92..5f8d3eed78a1 100644
> +--- a/tools/objtool/check.c
> ++++ b/tools/objtool/check.c
> +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> +
> +               /* populate reloc for 'addr' */
> +               reloc = malloc(sizeof(*reloc));
> ++
> +               if (!reloc) {
> +                       perror("malloc");
> +                       return -1;
> +               }
> +               memset(reloc, 0, sizeof(*reloc));
> +-              reloc->sym = insn->sec->sym;
> +-              reloc->addend = insn->offset;
> ++
> ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> ++              if (!reloc->sym) {
> ++                      WARN_FUNC("static call tramp: missing containing symbol",
> ++                                insn->sec, insn->offset);
> ++                      return -1;
> ++              }
> ++
> +               reloc->type = R_X86_64_PC32;
> +               reloc->offset = idx * sizeof(struct static_call_site);
> +               reloc->sec = reloc_sec;
> +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> +index 4e1d7460574b..be89c741ba9a 100644
> +--- a/tools/objtool/elf.c
> ++++ b/tools/objtool/elf.c
> +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> + }
> +
> ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> ++                            struct reloc *reloc)
> ++{
> ++      if (sec->sym) {
> ++              reloc->sym = sec->sym;
> ++              reloc->addend = offset;
> ++              return;
> ++      }
> ++
> ++      /*
> ++       * The Clang assembler strips section symbols, so we have to reference
> ++       * the function symbol instead:
> ++       */
> ++      reloc->sym = find_symbol_containing(sec, offset);
> ++      if (!reloc->sym) {
> ++              /*
> ++               * Hack alert.  This happens when we need to reference the NOP
> ++               * pad insn immediately after the function.
> ++               */
> ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> ++      }
> ++
> ++      if (reloc->sym)
> ++              reloc->addend = offset - reloc->sym->offset;
> ++}
> ++
> + static int read_sections(struct elf *elf)
> + {
> +       Elf_Scn *s = NULL;
> +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> +index 807f8c670097..e6890cc70a25 100644
> +--- a/tools/objtool/elf.h
> ++++ b/tools/objtool/elf.h
> +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> +                                    unsigned long offset, unsigned int len);
> + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> ++                            struct reloc *reloc);
> + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> +
> + #define for_each_sec(file, sec)                                               \
> +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> +index 235663b96adc..9ce68b385a1b 100644
> +--- a/tools/objtool/orc_gen.c
> ++++ b/tools/objtool/orc_gen.c
> +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> +       }
> +       memset(reloc, 0, sizeof(*reloc));
> +
> +-      if (insn_sec->sym) {
> +-              reloc->sym = insn_sec->sym;
> +-              reloc->addend = insn_off;
> +-      } else {
> +-              /*
> +-               * The Clang assembler doesn't produce section symbols, so we
> +-               * have to reference the function symbol instead:
> +-               */
> +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> +-              if (!reloc->sym) {
> +-                      /*
> +-                       * Hack alert.  This happens when we need to reference
> +-                       * the NOP pad insn immediately after the function.
> +-                       */
> +-                      reloc->sym = find_symbol_containing(insn_sec,
> +-                                                         insn_off - 1);
> +-              }
> +-              if (!reloc->sym) {
> +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> +-                           insn_off);
> +-                      return -1;
> +-              }
> +-
> +-              reloc->addend = insn_off - reloc->sym->offset;
> ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> ++      if (!reloc->sym) {
> ++              WARN("missing symbol for insn at offset 0x%lx",
> ++                   insn_off);
> ++              return -1;
> +       }
> +
> +       reloc->type = R_X86_64_PC32;
> +--
> +2.30.0
> +
> diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> new file mode 100644
> index 0000000000..320d7e929c
> --- /dev/null
> +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> @@ -0,0 +1,125 @@
> +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> +From: Nick Desaulniers <ndesaulniers@google.com>
> +Date: Tue, 12 Jan 2021 11:46:24 -0800
> +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> +
> +Arnd found a randconfig that produces the warning:
> +
> +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> +  offset 0x3e
> +
> +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> +notes:
> +
> +  With the LLVM assembler not generating section symbols, objtool has no
> +  way to reference this code when it generates ORC unwinder entries,
> +  because this code is outside of any ELF function.
> +
> +  The limitation now being imposed by objtool is that all code must be
> +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> +
> +  So basically, you can use an .L symbol *inside* a function or a code
> +  segment, you just can't use the .L symbol to contain the code using a
> +  SYM_*_START/END annotation pair.
> +
> +Fangrui notes that this optimization is helpful for reducing image size
> +when compiling with -ffunction-sections and -fdata-sections. I have
> +observed on the order of tens of thousands of symbols for the kernel
> +images built with those flags.
> +
> +A patch has been authored against GNU binutils to match this behavior
> +of not generating unused section symbols ([1]), so this will
> +also become a problem for users of GNU binutils once they upgrade to 2.36.
> +
> +Omit the .L prefix on a label so that the assembler will emit an entry
> +into the symbol table for the label, with STB_LOCAL binding. This
> +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> +GNU binutils 2.36+.
> +
> + [ bp: Massage commit message. ]
> +
> +Reported-by: Arnd Bergmann <arnd@arndb.de>
> +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> +Suggested-by: Borislav Petkov <bp@alien8.de>
> +Suggested-by: Mark Brown <broonie@kernel.org>
> +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> +Signed-off-by: Borislav Petkov <bp@suse.de>
> +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> +Link: https://reviews.llvm.org/D93783
> +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> +---
> + Documentation/asm-annotations.rst | 5 +++++
> + arch/x86/entry/thunk_64.S         | 8 ++++----
> + include/linux/linkage.h           | 5 +++++
> + 3 files changed, 14 insertions(+), 4 deletions(-)
> +
> +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> +index 32ea57483378..76424e0431f4 100644
> +--- a/Documentation/asm-annotations.rst
> ++++ b/Documentation/asm-annotations.rst
> +@@ -100,6 +100,11 @@ Instruction Macros
> + ~~~~~~~~~~~~~~~~~~
> + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> +
> ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> ++prefixed symbols can be used within a code region, but should be avoided for
> ++denoting a range of code via ``SYM_*_START/END`` annotations.
> ++
> + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> +   most frequent markings**. They are used for functions with standard calling
> +   conventions -- global and local. Like in C, they both align the functions to
> +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> +index ccd32877a3c4..c9a9fbf1655f 100644
> +--- a/arch/x86/entry/thunk_64.S
> ++++ b/arch/x86/entry/thunk_64.S
> +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> +       .endif
> +
> +       call \func
> +-      jmp  .L_restore
> ++      jmp  __thunk_restore
> + SYM_FUNC_END(\name)
> +       _ASM_NOKPROBE(\name)
> +       .endm
> +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> + #endif
> +
> + #ifdef CONFIG_PREEMPTION
> +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> +       popq %r11
> +       popq %r10
> +       popq %r9
> +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> +       popq %rdi
> +       popq %rbp
> +       ret
> +-      _ASM_NOKPROBE(.L_restore)
> +-SYM_CODE_END(.L_restore)
> ++      _ASM_NOKPROBE(__thunk_restore)
> ++SYM_CODE_END(__thunk_restore)
> + #endif
> +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> +index 5bcfbd972e97..dbf8506decca 100644
> +--- a/include/linux/linkage.h
> ++++ b/include/linux/linkage.h
> +@@ -178,6 +178,11 @@
> +  * Objtool generates debug info for both FUNC & CODE, but needs special
> +  * annotations for each CODE's start (to describe the actual stack frame).
> +  *
> ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> ++ * names that have a  .L prefix do not emit symbol table entries. .L
> ++ * prefixed symbols can be used within a code region, but should be avoided for
> ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> ++ *
> +  * ALIAS -- does not generate debug info -- the aliased function will
> +  */
> +
> +--
> +2.30.0
> +
> diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> index 7e570b04f5..aa328aff52 100644
> --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
>  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
>             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
>
> +SRC_URI += "\
> +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> +"
> +
>  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
>  LINUX_VERSION ?= "5.10.5"
>
> --
> 2.30.0
>
>
> 
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  3:12   ` [OE-core] " Bruce Ashfield
@ 2021-02-03  3:18     ` Khem Raj
  2021-02-03  3:26       ` Khem Raj
  0 siblings, 1 reply; 11+ messages in thread
From: Khem Raj @ 2021-02-03  3:18 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: Patches and discussions about the oe-core layer

Hi Bruce

Yeah :) it was my local series and as mentioned temp hack. I think we
will wait for your SRCREV bumps for final fix. but perhaps this can
help to temporarily testing master-next a bit.

On Tue, Feb 2, 2021 at 7:12 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
>
> Richard,
>
> Obviously ignore this patch.
>
> It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
> it's a hassle to have to wonder if this has been applied, have a
> failure, sent a revert, etc.
>
> I'm not even sure why it was sent.
>
> Bruce
>
> On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > This is for master-next testing only !!
> >
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
> >  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
> >  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
> >  3 files changed, 280 insertions(+)
> >  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> >  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> >
> > diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > new file mode 100644
> > index 0000000000..f606e3ee6d
> > --- /dev/null
> > +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > @@ -0,0 +1,150 @@
> > +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> > +From: Josh Poimboeuf <jpoimboe@redhat.com>
> > +Date: Mon, 14 Dec 2020 16:04:20 -0600
> > +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> > +
> > +The Clang assembler likes to strip section symbols, which means objtool
> > +can't reference some text code by its section.  This confuses objtool
> > +greatly, causing it to seg fault.
> > +
> > +The fix is similar to what was done before, for ORC reloc generation:
> > +
> > +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> > +
> > +Factor out that code into a common helper and use it for static call
> > +reloc generation as well.
> > +
> > +Reported-by: Arnd Bergmann <arnd@kernel.org>
> > +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> > +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> > +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> > +---
> > + tools/objtool/check.c   | 11 +++++++++--
> > + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> > + tools/objtool/elf.h     |  2 ++
> > + tools/objtool/orc_gen.c | 29 +++++------------------------
> > + 4 files changed, 42 insertions(+), 26 deletions(-)
> > +
> > +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > +index c6ab44543c92..5f8d3eed78a1 100644
> > +--- a/tools/objtool/check.c
> > ++++ b/tools/objtool/check.c
> > +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> > +
> > +               /* populate reloc for 'addr' */
> > +               reloc = malloc(sizeof(*reloc));
> > ++
> > +               if (!reloc) {
> > +                       perror("malloc");
> > +                       return -1;
> > +               }
> > +               memset(reloc, 0, sizeof(*reloc));
> > +-              reloc->sym = insn->sec->sym;
> > +-              reloc->addend = insn->offset;
> > ++
> > ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> > ++              if (!reloc->sym) {
> > ++                      WARN_FUNC("static call tramp: missing containing symbol",
> > ++                                insn->sec, insn->offset);
> > ++                      return -1;
> > ++              }
> > ++
> > +               reloc->type = R_X86_64_PC32;
> > +               reloc->offset = idx * sizeof(struct static_call_site);
> > +               reloc->sec = reloc_sec;
> > +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> > +index 4e1d7460574b..be89c741ba9a 100644
> > +--- a/tools/objtool/elf.c
> > ++++ b/tools/objtool/elf.c
> > +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> > + }
> > +
> > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > ++                            struct reloc *reloc)
> > ++{
> > ++      if (sec->sym) {
> > ++              reloc->sym = sec->sym;
> > ++              reloc->addend = offset;
> > ++              return;
> > ++      }
> > ++
> > ++      /*
> > ++       * The Clang assembler strips section symbols, so we have to reference
> > ++       * the function symbol instead:
> > ++       */
> > ++      reloc->sym = find_symbol_containing(sec, offset);
> > ++      if (!reloc->sym) {
> > ++              /*
> > ++               * Hack alert.  This happens when we need to reference the NOP
> > ++               * pad insn immediately after the function.
> > ++               */
> > ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> > ++      }
> > ++
> > ++      if (reloc->sym)
> > ++              reloc->addend = offset - reloc->sym->offset;
> > ++}
> > ++
> > + static int read_sections(struct elf *elf)
> > + {
> > +       Elf_Scn *s = NULL;
> > +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> > +index 807f8c670097..e6890cc70a25 100644
> > +--- a/tools/objtool/elf.h
> > ++++ b/tools/objtool/elf.h
> > +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> > +                                    unsigned long offset, unsigned int len);
> > + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > ++                            struct reloc *reloc);
> > + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> > +
> > + #define for_each_sec(file, sec)                                               \
> > +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> > +index 235663b96adc..9ce68b385a1b 100644
> > +--- a/tools/objtool/orc_gen.c
> > ++++ b/tools/objtool/orc_gen.c
> > +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> > +       }
> > +       memset(reloc, 0, sizeof(*reloc));
> > +
> > +-      if (insn_sec->sym) {
> > +-              reloc->sym = insn_sec->sym;
> > +-              reloc->addend = insn_off;
> > +-      } else {
> > +-              /*
> > +-               * The Clang assembler doesn't produce section symbols, so we
> > +-               * have to reference the function symbol instead:
> > +-               */
> > +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> > +-              if (!reloc->sym) {
> > +-                      /*
> > +-                       * Hack alert.  This happens when we need to reference
> > +-                       * the NOP pad insn immediately after the function.
> > +-                       */
> > +-                      reloc->sym = find_symbol_containing(insn_sec,
> > +-                                                         insn_off - 1);
> > +-              }
> > +-              if (!reloc->sym) {
> > +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> > +-                           insn_off);
> > +-                      return -1;
> > +-              }
> > +-
> > +-              reloc->addend = insn_off - reloc->sym->offset;
> > ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> > ++      if (!reloc->sym) {
> > ++              WARN("missing symbol for insn at offset 0x%lx",
> > ++                   insn_off);
> > ++              return -1;
> > +       }
> > +
> > +       reloc->type = R_X86_64_PC32;
> > +--
> > +2.30.0
> > +
> > diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > new file mode 100644
> > index 0000000000..320d7e929c
> > --- /dev/null
> > +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > @@ -0,0 +1,125 @@
> > +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> > +From: Nick Desaulniers <ndesaulniers@google.com>
> > +Date: Tue, 12 Jan 2021 11:46:24 -0800
> > +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> > +
> > +Arnd found a randconfig that produces the warning:
> > +
> > +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> > +  offset 0x3e
> > +
> > +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> > +notes:
> > +
> > +  With the LLVM assembler not generating section symbols, objtool has no
> > +  way to reference this code when it generates ORC unwinder entries,
> > +  because this code is outside of any ELF function.
> > +
> > +  The limitation now being imposed by objtool is that all code must be
> > +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> > +
> > +  So basically, you can use an .L symbol *inside* a function or a code
> > +  segment, you just can't use the .L symbol to contain the code using a
> > +  SYM_*_START/END annotation pair.
> > +
> > +Fangrui notes that this optimization is helpful for reducing image size
> > +when compiling with -ffunction-sections and -fdata-sections. I have
> > +observed on the order of tens of thousands of symbols for the kernel
> > +images built with those flags.
> > +
> > +A patch has been authored against GNU binutils to match this behavior
> > +of not generating unused section symbols ([1]), so this will
> > +also become a problem for users of GNU binutils once they upgrade to 2.36.
> > +
> > +Omit the .L prefix on a label so that the assembler will emit an entry
> > +into the symbol table for the label, with STB_LOCAL binding. This
> > +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> > +GNU binutils 2.36+.
> > +
> > + [ bp: Massage commit message. ]
> > +
> > +Reported-by: Arnd Bergmann <arnd@arndb.de>
> > +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > +Suggested-by: Borislav Petkov <bp@alien8.de>
> > +Suggested-by: Mark Brown <broonie@kernel.org>
> > +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > +Signed-off-by: Borislav Petkov <bp@suse.de>
> > +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> > +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> > +Link: https://reviews.llvm.org/D93783
> > +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> > +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> > +---
> > + Documentation/asm-annotations.rst | 5 +++++
> > + arch/x86/entry/thunk_64.S         | 8 ++++----
> > + include/linux/linkage.h           | 5 +++++
> > + 3 files changed, 14 insertions(+), 4 deletions(-)
> > +
> > +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> > +index 32ea57483378..76424e0431f4 100644
> > +--- a/Documentation/asm-annotations.rst
> > ++++ b/Documentation/asm-annotations.rst
> > +@@ -100,6 +100,11 @@ Instruction Macros
> > + ~~~~~~~~~~~~~~~~~~
> > + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> > +
> > ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> > ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> > ++prefixed symbols can be used within a code region, but should be avoided for
> > ++denoting a range of code via ``SYM_*_START/END`` annotations.
> > ++
> > + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> > +   most frequent markings**. They are used for functions with standard calling
> > +   conventions -- global and local. Like in C, they both align the functions to
> > +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> > +index ccd32877a3c4..c9a9fbf1655f 100644
> > +--- a/arch/x86/entry/thunk_64.S
> > ++++ b/arch/x86/entry/thunk_64.S
> > +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> > +       .endif
> > +
> > +       call \func
> > +-      jmp  .L_restore
> > ++      jmp  __thunk_restore
> > + SYM_FUNC_END(\name)
> > +       _ASM_NOKPROBE(\name)
> > +       .endm
> > +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> > + #endif
> > +
> > + #ifdef CONFIG_PREEMPTION
> > +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> > +       popq %r11
> > +       popq %r10
> > +       popq %r9
> > +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > +       popq %rdi
> > +       popq %rbp
> > +       ret
> > +-      _ASM_NOKPROBE(.L_restore)
> > +-SYM_CODE_END(.L_restore)
> > ++      _ASM_NOKPROBE(__thunk_restore)
> > ++SYM_CODE_END(__thunk_restore)
> > + #endif
> > +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> > +index 5bcfbd972e97..dbf8506decca 100644
> > +--- a/include/linux/linkage.h
> > ++++ b/include/linux/linkage.h
> > +@@ -178,6 +178,11 @@
> > +  * Objtool generates debug info for both FUNC & CODE, but needs special
> > +  * annotations for each CODE's start (to describe the actual stack frame).
> > +  *
> > ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> > ++ * names that have a  .L prefix do not emit symbol table entries. .L
> > ++ * prefixed symbols can be used within a code region, but should be avoided for
> > ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> > ++ *
> > +  * ALIAS -- does not generate debug info -- the aliased function will
> > +  */
> > +
> > +--
> > +2.30.0
> > +
> > diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > index 7e570b04f5..aa328aff52 100644
> > --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
> >  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
> >             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
> >
> > +SRC_URI += "\
> > +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> > +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> > +"
> > +
> >  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
> >  LINUX_VERSION ?= "5.10.5"
> >
> > --
> > 2.30.0
> >
> >
> > 
> >
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  3:18     ` Khem Raj
@ 2021-02-03  3:26       ` Khem Raj
  2021-02-03  3:28         ` Bruce Ashfield
  0 siblings, 1 reply; 11+ messages in thread
From: Khem Raj @ 2021-02-03  3:26 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: Patches and discussions about the oe-core layer

ah I see your patch series, does this include above two patches ?

On Tue, Feb 2, 2021 at 7:18 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> Hi Bruce
>
> Yeah :) it was my local series and as mentioned temp hack. I think we
> will wait for your SRCREV bumps for final fix. but perhaps this can
> help to temporarily testing master-next a bit.
>
> On Tue, Feb 2, 2021 at 7:12 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> >
> > Richard,
> >
> > Obviously ignore this patch.
> >
> > It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
> > it's a hassle to have to wonder if this has been applied, have a
> > failure, sent a revert, etc.
> >
> > I'm not even sure why it was sent.
> >
> > Bruce
> >
> > On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
> > >
> > > This is for master-next testing only !!
> > >
> > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > ---
> > >  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
> > >  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
> > >  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
> > >  3 files changed, 280 insertions(+)
> > >  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > >  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > >
> > > diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > new file mode 100644
> > > index 0000000000..f606e3ee6d
> > > --- /dev/null
> > > +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > @@ -0,0 +1,150 @@
> > > +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> > > +From: Josh Poimboeuf <jpoimboe@redhat.com>
> > > +Date: Mon, 14 Dec 2020 16:04:20 -0600
> > > +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> > > +
> > > +The Clang assembler likes to strip section symbols, which means objtool
> > > +can't reference some text code by its section.  This confuses objtool
> > > +greatly, causing it to seg fault.
> > > +
> > > +The fix is similar to what was done before, for ORC reloc generation:
> > > +
> > > +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> > > +
> > > +Factor out that code into a common helper and use it for static call
> > > +reloc generation as well.
> > > +
> > > +Reported-by: Arnd Bergmann <arnd@kernel.org>
> > > +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > > +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> > > +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> > > +---
> > > + tools/objtool/check.c   | 11 +++++++++--
> > > + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> > > + tools/objtool/elf.h     |  2 ++
> > > + tools/objtool/orc_gen.c | 29 +++++------------------------
> > > + 4 files changed, 42 insertions(+), 26 deletions(-)
> > > +
> > > +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > > +index c6ab44543c92..5f8d3eed78a1 100644
> > > +--- a/tools/objtool/check.c
> > > ++++ b/tools/objtool/check.c
> > > +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> > > +
> > > +               /* populate reloc for 'addr' */
> > > +               reloc = malloc(sizeof(*reloc));
> > > ++
> > > +               if (!reloc) {
> > > +                       perror("malloc");
> > > +                       return -1;
> > > +               }
> > > +               memset(reloc, 0, sizeof(*reloc));
> > > +-              reloc->sym = insn->sec->sym;
> > > +-              reloc->addend = insn->offset;
> > > ++
> > > ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> > > ++              if (!reloc->sym) {
> > > ++                      WARN_FUNC("static call tramp: missing containing symbol",
> > > ++                                insn->sec, insn->offset);
> > > ++                      return -1;
> > > ++              }
> > > ++
> > > +               reloc->type = R_X86_64_PC32;
> > > +               reloc->offset = idx * sizeof(struct static_call_site);
> > > +               reloc->sec = reloc_sec;
> > > +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> > > +index 4e1d7460574b..be89c741ba9a 100644
> > > +--- a/tools/objtool/elf.c
> > > ++++ b/tools/objtool/elf.c
> > > +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> > > + }
> > > +
> > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > ++                            struct reloc *reloc)
> > > ++{
> > > ++      if (sec->sym) {
> > > ++              reloc->sym = sec->sym;
> > > ++              reloc->addend = offset;
> > > ++              return;
> > > ++      }
> > > ++
> > > ++      /*
> > > ++       * The Clang assembler strips section symbols, so we have to reference
> > > ++       * the function symbol instead:
> > > ++       */
> > > ++      reloc->sym = find_symbol_containing(sec, offset);
> > > ++      if (!reloc->sym) {
> > > ++              /*
> > > ++               * Hack alert.  This happens when we need to reference the NOP
> > > ++               * pad insn immediately after the function.
> > > ++               */
> > > ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> > > ++      }
> > > ++
> > > ++      if (reloc->sym)
> > > ++              reloc->addend = offset - reloc->sym->offset;
> > > ++}
> > > ++
> > > + static int read_sections(struct elf *elf)
> > > + {
> > > +       Elf_Scn *s = NULL;
> > > +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> > > +index 807f8c670097..e6890cc70a25 100644
> > > +--- a/tools/objtool/elf.h
> > > ++++ b/tools/objtool/elf.h
> > > +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> > > +                                    unsigned long offset, unsigned int len);
> > > + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > ++                            struct reloc *reloc);
> > > + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> > > +
> > > + #define for_each_sec(file, sec)                                               \
> > > +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> > > +index 235663b96adc..9ce68b385a1b 100644
> > > +--- a/tools/objtool/orc_gen.c
> > > ++++ b/tools/objtool/orc_gen.c
> > > +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> > > +       }
> > > +       memset(reloc, 0, sizeof(*reloc));
> > > +
> > > +-      if (insn_sec->sym) {
> > > +-              reloc->sym = insn_sec->sym;
> > > +-              reloc->addend = insn_off;
> > > +-      } else {
> > > +-              /*
> > > +-               * The Clang assembler doesn't produce section symbols, so we
> > > +-               * have to reference the function symbol instead:
> > > +-               */
> > > +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> > > +-              if (!reloc->sym) {
> > > +-                      /*
> > > +-                       * Hack alert.  This happens when we need to reference
> > > +-                       * the NOP pad insn immediately after the function.
> > > +-                       */
> > > +-                      reloc->sym = find_symbol_containing(insn_sec,
> > > +-                                                         insn_off - 1);
> > > +-              }
> > > +-              if (!reloc->sym) {
> > > +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> > > +-                           insn_off);
> > > +-                      return -1;
> > > +-              }
> > > +-
> > > +-              reloc->addend = insn_off - reloc->sym->offset;
> > > ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> > > ++      if (!reloc->sym) {
> > > ++              WARN("missing symbol for insn at offset 0x%lx",
> > > ++                   insn_off);
> > > ++              return -1;
> > > +       }
> > > +
> > > +       reloc->type = R_X86_64_PC32;
> > > +--
> > > +2.30.0
> > > +
> > > diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > new file mode 100644
> > > index 0000000000..320d7e929c
> > > --- /dev/null
> > > +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > @@ -0,0 +1,125 @@
> > > +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> > > +From: Nick Desaulniers <ndesaulniers@google.com>
> > > +Date: Tue, 12 Jan 2021 11:46:24 -0800
> > > +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> > > +
> > > +Arnd found a randconfig that produces the warning:
> > > +
> > > +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> > > +  offset 0x3e
> > > +
> > > +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> > > +notes:
> > > +
> > > +  With the LLVM assembler not generating section symbols, objtool has no
> > > +  way to reference this code when it generates ORC unwinder entries,
> > > +  because this code is outside of any ELF function.
> > > +
> > > +  The limitation now being imposed by objtool is that all code must be
> > > +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> > > +
> > > +  So basically, you can use an .L symbol *inside* a function or a code
> > > +  segment, you just can't use the .L symbol to contain the code using a
> > > +  SYM_*_START/END annotation pair.
> > > +
> > > +Fangrui notes that this optimization is helpful for reducing image size
> > > +when compiling with -ffunction-sections and -fdata-sections. I have
> > > +observed on the order of tens of thousands of symbols for the kernel
> > > +images built with those flags.
> > > +
> > > +A patch has been authored against GNU binutils to match this behavior
> > > +of not generating unused section symbols ([1]), so this will
> > > +also become a problem for users of GNU binutils once they upgrade to 2.36.
> > > +
> > > +Omit the .L prefix on a label so that the assembler will emit an entry
> > > +into the symbol table for the label, with STB_LOCAL binding. This
> > > +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> > > +GNU binutils 2.36+.
> > > +
> > > + [ bp: Massage commit message. ]
> > > +
> > > +Reported-by: Arnd Bergmann <arnd@arndb.de>
> > > +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > +Suggested-by: Borislav Petkov <bp@alien8.de>
> > > +Suggested-by: Mark Brown <broonie@kernel.org>
> > > +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > +Signed-off-by: Borislav Petkov <bp@suse.de>
> > > +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> > > +Link: https://reviews.llvm.org/D93783
> > > +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> > > +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> > > +---
> > > + Documentation/asm-annotations.rst | 5 +++++
> > > + arch/x86/entry/thunk_64.S         | 8 ++++----
> > > + include/linux/linkage.h           | 5 +++++
> > > + 3 files changed, 14 insertions(+), 4 deletions(-)
> > > +
> > > +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> > > +index 32ea57483378..76424e0431f4 100644
> > > +--- a/Documentation/asm-annotations.rst
> > > ++++ b/Documentation/asm-annotations.rst
> > > +@@ -100,6 +100,11 @@ Instruction Macros
> > > + ~~~~~~~~~~~~~~~~~~
> > > + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> > > +
> > > ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> > > ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> > > ++prefixed symbols can be used within a code region, but should be avoided for
> > > ++denoting a range of code via ``SYM_*_START/END`` annotations.
> > > ++
> > > + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> > > +   most frequent markings**. They are used for functions with standard calling
> > > +   conventions -- global and local. Like in C, they both align the functions to
> > > +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> > > +index ccd32877a3c4..c9a9fbf1655f 100644
> > > +--- a/arch/x86/entry/thunk_64.S
> > > ++++ b/arch/x86/entry/thunk_64.S
> > > +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> > > +       .endif
> > > +
> > > +       call \func
> > > +-      jmp  .L_restore
> > > ++      jmp  __thunk_restore
> > > + SYM_FUNC_END(\name)
> > > +       _ASM_NOKPROBE(\name)
> > > +       .endm
> > > +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> > > + #endif
> > > +
> > > + #ifdef CONFIG_PREEMPTION
> > > +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> > > +       popq %r11
> > > +       popq %r10
> > > +       popq %r9
> > > +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > +       popq %rdi
> > > +       popq %rbp
> > > +       ret
> > > +-      _ASM_NOKPROBE(.L_restore)
> > > +-SYM_CODE_END(.L_restore)
> > > ++      _ASM_NOKPROBE(__thunk_restore)
> > > ++SYM_CODE_END(__thunk_restore)
> > > + #endif
> > > +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> > > +index 5bcfbd972e97..dbf8506decca 100644
> > > +--- a/include/linux/linkage.h
> > > ++++ b/include/linux/linkage.h
> > > +@@ -178,6 +178,11 @@
> > > +  * Objtool generates debug info for both FUNC & CODE, but needs special
> > > +  * annotations for each CODE's start (to describe the actual stack frame).
> > > +  *
> > > ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> > > ++ * names that have a  .L prefix do not emit symbol table entries. .L
> > > ++ * prefixed symbols can be used within a code region, but should be avoided for
> > > ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> > > ++ *
> > > +  * ALIAS -- does not generate debug info -- the aliased function will
> > > +  */
> > > +
> > > +--
> > > +2.30.0
> > > +
> > > diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > index 7e570b04f5..aa328aff52 100644
> > > --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
> > >  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
> > >             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
> > >
> > > +SRC_URI += "\
> > > +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> > > +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> > > +"
> > > +
> > >  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
> > >  LINUX_VERSION ?= "5.10.5"
> > >
> > > --
> > > 2.30.0
> > >
> > >
> > > 
> > >
> >
> >
> > --
> > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > thee at its end
> > - "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  3:26       ` Khem Raj
@ 2021-02-03  3:28         ` Bruce Ashfield
  2021-02-03  3:38           ` Khem Raj
  0 siblings, 1 reply; 11+ messages in thread
From: Bruce Ashfield @ 2021-02-03  3:28 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

On Tue, Feb 2, 2021 at 10:26 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> ah I see your patch series, does this include above two patches ?

It does yes.

My local build worked, and since you confirmed they were good for the
binutils fix, I cherry picked them on that basis.

I did notice that they failed to cherry-pick to v5.4 though, so if
want that to work with the new binutils, we have work to do, or wait
for -stable. Let me know if you are looking at it, otherwise, I'll see
what needs to be done tonight/tomorrow.

Bruce

>
> On Tue, Feb 2, 2021 at 7:18 PM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > Hi Bruce
> >
> > Yeah :) it was my local series and as mentioned temp hack. I think we
> > will wait for your SRCREV bumps for final fix. but perhaps this can
> > help to temporarily testing master-next a bit.
> >
> > On Tue, Feb 2, 2021 at 7:12 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> > >
> > > Richard,
> > >
> > > Obviously ignore this patch.
> > >
> > > It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
> > > it's a hassle to have to wonder if this has been applied, have a
> > > failure, sent a revert, etc.
> > >
> > > I'm not even sure why it was sent.
> > >
> > > Bruce
> > >
> > > On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
> > > >
> > > > This is for master-next testing only !!
> > > >
> > > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > > ---
> > > >  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
> > > >  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
> > > >  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
> > > >  3 files changed, 280 insertions(+)
> > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > >
> > > > diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > new file mode 100644
> > > > index 0000000000..f606e3ee6d
> > > > --- /dev/null
> > > > +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > @@ -0,0 +1,150 @@
> > > > +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> > > > +From: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > +Date: Mon, 14 Dec 2020 16:04:20 -0600
> > > > +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> > > > +
> > > > +The Clang assembler likes to strip section symbols, which means objtool
> > > > +can't reference some text code by its section.  This confuses objtool
> > > > +greatly, causing it to seg fault.
> > > > +
> > > > +The fix is similar to what was done before, for ORC reloc generation:
> > > > +
> > > > +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> > > > +
> > > > +Factor out that code into a common helper and use it for static call
> > > > +reloc generation as well.
> > > > +
> > > > +Reported-by: Arnd Bergmann <arnd@kernel.org>
> > > > +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> > > > +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> > > > +---
> > > > + tools/objtool/check.c   | 11 +++++++++--
> > > > + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> > > > + tools/objtool/elf.h     |  2 ++
> > > > + tools/objtool/orc_gen.c | 29 +++++------------------------
> > > > + 4 files changed, 42 insertions(+), 26 deletions(-)
> > > > +
> > > > +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > > > +index c6ab44543c92..5f8d3eed78a1 100644
> > > > +--- a/tools/objtool/check.c
> > > > ++++ b/tools/objtool/check.c
> > > > +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> > > > +
> > > > +               /* populate reloc for 'addr' */
> > > > +               reloc = malloc(sizeof(*reloc));
> > > > ++
> > > > +               if (!reloc) {
> > > > +                       perror("malloc");
> > > > +                       return -1;
> > > > +               }
> > > > +               memset(reloc, 0, sizeof(*reloc));
> > > > +-              reloc->sym = insn->sec->sym;
> > > > +-              reloc->addend = insn->offset;
> > > > ++
> > > > ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> > > > ++              if (!reloc->sym) {
> > > > ++                      WARN_FUNC("static call tramp: missing containing symbol",
> > > > ++                                insn->sec, insn->offset);
> > > > ++                      return -1;
> > > > ++              }
> > > > ++
> > > > +               reloc->type = R_X86_64_PC32;
> > > > +               reloc->offset = idx * sizeof(struct static_call_site);
> > > > +               reloc->sec = reloc_sec;
> > > > +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> > > > +index 4e1d7460574b..be89c741ba9a 100644
> > > > +--- a/tools/objtool/elf.c
> > > > ++++ b/tools/objtool/elf.c
> > > > +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> > > > + }
> > > > +
> > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > ++                            struct reloc *reloc)
> > > > ++{
> > > > ++      if (sec->sym) {
> > > > ++              reloc->sym = sec->sym;
> > > > ++              reloc->addend = offset;
> > > > ++              return;
> > > > ++      }
> > > > ++
> > > > ++      /*
> > > > ++       * The Clang assembler strips section symbols, so we have to reference
> > > > ++       * the function symbol instead:
> > > > ++       */
> > > > ++      reloc->sym = find_symbol_containing(sec, offset);
> > > > ++      if (!reloc->sym) {
> > > > ++              /*
> > > > ++               * Hack alert.  This happens when we need to reference the NOP
> > > > ++               * pad insn immediately after the function.
> > > > ++               */
> > > > ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> > > > ++      }
> > > > ++
> > > > ++      if (reloc->sym)
> > > > ++              reloc->addend = offset - reloc->sym->offset;
> > > > ++}
> > > > ++
> > > > + static int read_sections(struct elf *elf)
> > > > + {
> > > > +       Elf_Scn *s = NULL;
> > > > +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> > > > +index 807f8c670097..e6890cc70a25 100644
> > > > +--- a/tools/objtool/elf.h
> > > > ++++ b/tools/objtool/elf.h
> > > > +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> > > > +                                    unsigned long offset, unsigned int len);
> > > > + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > ++                            struct reloc *reloc);
> > > > + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> > > > +
> > > > + #define for_each_sec(file, sec)                                               \
> > > > +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> > > > +index 235663b96adc..9ce68b385a1b 100644
> > > > +--- a/tools/objtool/orc_gen.c
> > > > ++++ b/tools/objtool/orc_gen.c
> > > > +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> > > > +       }
> > > > +       memset(reloc, 0, sizeof(*reloc));
> > > > +
> > > > +-      if (insn_sec->sym) {
> > > > +-              reloc->sym = insn_sec->sym;
> > > > +-              reloc->addend = insn_off;
> > > > +-      } else {
> > > > +-              /*
> > > > +-               * The Clang assembler doesn't produce section symbols, so we
> > > > +-               * have to reference the function symbol instead:
> > > > +-               */
> > > > +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> > > > +-              if (!reloc->sym) {
> > > > +-                      /*
> > > > +-                       * Hack alert.  This happens when we need to reference
> > > > +-                       * the NOP pad insn immediately after the function.
> > > > +-                       */
> > > > +-                      reloc->sym = find_symbol_containing(insn_sec,
> > > > +-                                                         insn_off - 1);
> > > > +-              }
> > > > +-              if (!reloc->sym) {
> > > > +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> > > > +-                           insn_off);
> > > > +-                      return -1;
> > > > +-              }
> > > > +-
> > > > +-              reloc->addend = insn_off - reloc->sym->offset;
> > > > ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> > > > ++      if (!reloc->sym) {
> > > > ++              WARN("missing symbol for insn at offset 0x%lx",
> > > > ++                   insn_off);
> > > > ++              return -1;
> > > > +       }
> > > > +
> > > > +       reloc->type = R_X86_64_PC32;
> > > > +--
> > > > +2.30.0
> > > > +
> > > > diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > new file mode 100644
> > > > index 0000000000..320d7e929c
> > > > --- /dev/null
> > > > +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > @@ -0,0 +1,125 @@
> > > > +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> > > > +From: Nick Desaulniers <ndesaulniers@google.com>
> > > > +Date: Tue, 12 Jan 2021 11:46:24 -0800
> > > > +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> > > > +
> > > > +Arnd found a randconfig that produces the warning:
> > > > +
> > > > +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> > > > +  offset 0x3e
> > > > +
> > > > +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> > > > +notes:
> > > > +
> > > > +  With the LLVM assembler not generating section symbols, objtool has no
> > > > +  way to reference this code when it generates ORC unwinder entries,
> > > > +  because this code is outside of any ELF function.
> > > > +
> > > > +  The limitation now being imposed by objtool is that all code must be
> > > > +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> > > > +
> > > > +  So basically, you can use an .L symbol *inside* a function or a code
> > > > +  segment, you just can't use the .L symbol to contain the code using a
> > > > +  SYM_*_START/END annotation pair.
> > > > +
> > > > +Fangrui notes that this optimization is helpful for reducing image size
> > > > +when compiling with -ffunction-sections and -fdata-sections. I have
> > > > +observed on the order of tens of thousands of symbols for the kernel
> > > > +images built with those flags.
> > > > +
> > > > +A patch has been authored against GNU binutils to match this behavior
> > > > +of not generating unused section symbols ([1]), so this will
> > > > +also become a problem for users of GNU binutils once they upgrade to 2.36.
> > > > +
> > > > +Omit the .L prefix on a label so that the assembler will emit an entry
> > > > +into the symbol table for the label, with STB_LOCAL binding. This
> > > > +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> > > > +GNU binutils 2.36+.
> > > > +
> > > > + [ bp: Massage commit message. ]
> > > > +
> > > > +Reported-by: Arnd Bergmann <arnd@arndb.de>
> > > > +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > +Suggested-by: Borislav Petkov <bp@alien8.de>
> > > > +Suggested-by: Mark Brown <broonie@kernel.org>
> > > > +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > +Signed-off-by: Borislav Petkov <bp@suse.de>
> > > > +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> > > > +Link: https://reviews.llvm.org/D93783
> > > > +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> > > > +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> > > > +---
> > > > + Documentation/asm-annotations.rst | 5 +++++
> > > > + arch/x86/entry/thunk_64.S         | 8 ++++----
> > > > + include/linux/linkage.h           | 5 +++++
> > > > + 3 files changed, 14 insertions(+), 4 deletions(-)
> > > > +
> > > > +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> > > > +index 32ea57483378..76424e0431f4 100644
> > > > +--- a/Documentation/asm-annotations.rst
> > > > ++++ b/Documentation/asm-annotations.rst
> > > > +@@ -100,6 +100,11 @@ Instruction Macros
> > > > + ~~~~~~~~~~~~~~~~~~
> > > > + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> > > > +
> > > > ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> > > > ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> > > > ++prefixed symbols can be used within a code region, but should be avoided for
> > > > ++denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > ++
> > > > + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> > > > +   most frequent markings**. They are used for functions with standard calling
> > > > +   conventions -- global and local. Like in C, they both align the functions to
> > > > +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> > > > +index ccd32877a3c4..c9a9fbf1655f 100644
> > > > +--- a/arch/x86/entry/thunk_64.S
> > > > ++++ b/arch/x86/entry/thunk_64.S
> > > > +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> > > > +       .endif
> > > > +
> > > > +       call \func
> > > > +-      jmp  .L_restore
> > > > ++      jmp  __thunk_restore
> > > > + SYM_FUNC_END(\name)
> > > > +       _ASM_NOKPROBE(\name)
> > > > +       .endm
> > > > +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> > > > + #endif
> > > > +
> > > > + #ifdef CONFIG_PREEMPTION
> > > > +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> > > > +       popq %r11
> > > > +       popq %r10
> > > > +       popq %r9
> > > > +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > +       popq %rdi
> > > > +       popq %rbp
> > > > +       ret
> > > > +-      _ASM_NOKPROBE(.L_restore)
> > > > +-SYM_CODE_END(.L_restore)
> > > > ++      _ASM_NOKPROBE(__thunk_restore)
> > > > ++SYM_CODE_END(__thunk_restore)
> > > > + #endif
> > > > +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> > > > +index 5bcfbd972e97..dbf8506decca 100644
> > > > +--- a/include/linux/linkage.h
> > > > ++++ b/include/linux/linkage.h
> > > > +@@ -178,6 +178,11 @@
> > > > +  * Objtool generates debug info for both FUNC & CODE, but needs special
> > > > +  * annotations for each CODE's start (to describe the actual stack frame).
> > > > +  *
> > > > ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> > > > ++ * names that have a  .L prefix do not emit symbol table entries. .L
> > > > ++ * prefixed symbols can be used within a code region, but should be avoided for
> > > > ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > ++ *
> > > > +  * ALIAS -- does not generate debug info -- the aliased function will
> > > > +  */
> > > > +
> > > > +--
> > > > +2.30.0
> > > > +
> > > > diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > index 7e570b04f5..aa328aff52 100644
> > > > --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
> > > >  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
> > > >             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
> > > >
> > > > +SRC_URI += "\
> > > > +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> > > > +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> > > > +"
> > > > +
> > > >  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
> > > >  LINUX_VERSION ?= "5.10.5"
> > > >
> > > > --
> > > > 2.30.0
> > > >
> > > >
> > > > 
> > > >
> > >
> > >
> > > --
> > > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > > thee at its end
> > > - "Use the force Harry" - Gandalf, Star Trek II



-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  3:28         ` Bruce Ashfield
@ 2021-02-03  3:38           ` Khem Raj
  2021-02-03  3:43             ` Bruce Ashfield
  0 siblings, 1 reply; 11+ messages in thread
From: Khem Raj @ 2021-02-03  3:38 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: Patches and discussions about the oe-core layer

I am not looking at 5.4 since the issue is x86 specific and all x86
BSPs on master are already on 5.10 perhaps we wont need to backport it
immediately

On Tue, Feb 2, 2021 at 7:29 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
>
> On Tue, Feb 2, 2021 at 10:26 PM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > ah I see your patch series, does this include above two patches ?
>
> It does yes.
>
> My local build worked, and since you confirmed they were good for the
> binutils fix, I cherry picked them on that basis.
>
> I did notice that they failed to cherry-pick to v5.4 though, so if
> want that to work with the new binutils, we have work to do, or wait
> for -stable. Let me know if you are looking at it, otherwise, I'll see
> what needs to be done tonight/tomorrow.
>
> Bruce
>
> >
> > On Tue, Feb 2, 2021 at 7:18 PM Khem Raj <raj.khem@gmail.com> wrote:
> > >
> > > Hi Bruce
> > >
> > > Yeah :) it was my local series and as mentioned temp hack. I think we
> > > will wait for your SRCREV bumps for final fix. but perhaps this can
> > > help to temporarily testing master-next a bit.
> > >
> > > On Tue, Feb 2, 2021 at 7:12 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> > > >
> > > > Richard,
> > > >
> > > > Obviously ignore this patch.
> > > >
> > > > It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
> > > > it's a hassle to have to wonder if this has been applied, have a
> > > > failure, sent a revert, etc.
> > > >
> > > > I'm not even sure why it was sent.
> > > >
> > > > Bruce
> > > >
> > > > On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
> > > > >
> > > > > This is for master-next testing only !!
> > > > >
> > > > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > > > ---
> > > > >  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
> > > > >  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
> > > > >  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
> > > > >  3 files changed, 280 insertions(+)
> > > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > >
> > > > > diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > > new file mode 100644
> > > > > index 0000000000..f606e3ee6d
> > > > > --- /dev/null
> > > > > +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > > @@ -0,0 +1,150 @@
> > > > > +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> > > > > +From: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > +Date: Mon, 14 Dec 2020 16:04:20 -0600
> > > > > +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> > > > > +
> > > > > +The Clang assembler likes to strip section symbols, which means objtool
> > > > > +can't reference some text code by its section.  This confuses objtool
> > > > > +greatly, causing it to seg fault.
> > > > > +
> > > > > +The fix is similar to what was done before, for ORC reloc generation:
> > > > > +
> > > > > +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> > > > > +
> > > > > +Factor out that code into a common helper and use it for static call
> > > > > +reloc generation as well.
> > > > > +
> > > > > +Reported-by: Arnd Bergmann <arnd@kernel.org>
> > > > > +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > > +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > > +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> > > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> > > > > +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> > > > > +---
> > > > > + tools/objtool/check.c   | 11 +++++++++--
> > > > > + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> > > > > + tools/objtool/elf.h     |  2 ++
> > > > > + tools/objtool/orc_gen.c | 29 +++++------------------------
> > > > > + 4 files changed, 42 insertions(+), 26 deletions(-)
> > > > > +
> > > > > +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > > > > +index c6ab44543c92..5f8d3eed78a1 100644
> > > > > +--- a/tools/objtool/check.c
> > > > > ++++ b/tools/objtool/check.c
> > > > > +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> > > > > +
> > > > > +               /* populate reloc for 'addr' */
> > > > > +               reloc = malloc(sizeof(*reloc));
> > > > > ++
> > > > > +               if (!reloc) {
> > > > > +                       perror("malloc");
> > > > > +                       return -1;
> > > > > +               }
> > > > > +               memset(reloc, 0, sizeof(*reloc));
> > > > > +-              reloc->sym = insn->sec->sym;
> > > > > +-              reloc->addend = insn->offset;
> > > > > ++
> > > > > ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> > > > > ++              if (!reloc->sym) {
> > > > > ++                      WARN_FUNC("static call tramp: missing containing symbol",
> > > > > ++                                insn->sec, insn->offset);
> > > > > ++                      return -1;
> > > > > ++              }
> > > > > ++
> > > > > +               reloc->type = R_X86_64_PC32;
> > > > > +               reloc->offset = idx * sizeof(struct static_call_site);
> > > > > +               reloc->sec = reloc_sec;
> > > > > +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> > > > > +index 4e1d7460574b..be89c741ba9a 100644
> > > > > +--- a/tools/objtool/elf.c
> > > > > ++++ b/tools/objtool/elf.c
> > > > > +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > > +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> > > > > + }
> > > > > +
> > > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > > ++                            struct reloc *reloc)
> > > > > ++{
> > > > > ++      if (sec->sym) {
> > > > > ++              reloc->sym = sec->sym;
> > > > > ++              reloc->addend = offset;
> > > > > ++              return;
> > > > > ++      }
> > > > > ++
> > > > > ++      /*
> > > > > ++       * The Clang assembler strips section symbols, so we have to reference
> > > > > ++       * the function symbol instead:
> > > > > ++       */
> > > > > ++      reloc->sym = find_symbol_containing(sec, offset);
> > > > > ++      if (!reloc->sym) {
> > > > > ++              /*
> > > > > ++               * Hack alert.  This happens when we need to reference the NOP
> > > > > ++               * pad insn immediately after the function.
> > > > > ++               */
> > > > > ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> > > > > ++      }
> > > > > ++
> > > > > ++      if (reloc->sym)
> > > > > ++              reloc->addend = offset - reloc->sym->offset;
> > > > > ++}
> > > > > ++
> > > > > + static int read_sections(struct elf *elf)
> > > > > + {
> > > > > +       Elf_Scn *s = NULL;
> > > > > +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> > > > > +index 807f8c670097..e6890cc70a25 100644
> > > > > +--- a/tools/objtool/elf.h
> > > > > ++++ b/tools/objtool/elf.h
> > > > > +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > > + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> > > > > +                                    unsigned long offset, unsigned int len);
> > > > > + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> > > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > > ++                            struct reloc *reloc);
> > > > > + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> > > > > +
> > > > > + #define for_each_sec(file, sec)                                               \
> > > > > +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> > > > > +index 235663b96adc..9ce68b385a1b 100644
> > > > > +--- a/tools/objtool/orc_gen.c
> > > > > ++++ b/tools/objtool/orc_gen.c
> > > > > +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> > > > > +       }
> > > > > +       memset(reloc, 0, sizeof(*reloc));
> > > > > +
> > > > > +-      if (insn_sec->sym) {
> > > > > +-              reloc->sym = insn_sec->sym;
> > > > > +-              reloc->addend = insn_off;
> > > > > +-      } else {
> > > > > +-              /*
> > > > > +-               * The Clang assembler doesn't produce section symbols, so we
> > > > > +-               * have to reference the function symbol instead:
> > > > > +-               */
> > > > > +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> > > > > +-              if (!reloc->sym) {
> > > > > +-                      /*
> > > > > +-                       * Hack alert.  This happens when we need to reference
> > > > > +-                       * the NOP pad insn immediately after the function.
> > > > > +-                       */
> > > > > +-                      reloc->sym = find_symbol_containing(insn_sec,
> > > > > +-                                                         insn_off - 1);
> > > > > +-              }
> > > > > +-              if (!reloc->sym) {
> > > > > +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> > > > > +-                           insn_off);
> > > > > +-                      return -1;
> > > > > +-              }
> > > > > +-
> > > > > +-              reloc->addend = insn_off - reloc->sym->offset;
> > > > > ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> > > > > ++      if (!reloc->sym) {
> > > > > ++              WARN("missing symbol for insn at offset 0x%lx",
> > > > > ++                   insn_off);
> > > > > ++              return -1;
> > > > > +       }
> > > > > +
> > > > > +       reloc->type = R_X86_64_PC32;
> > > > > +--
> > > > > +2.30.0
> > > > > +
> > > > > diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > > new file mode 100644
> > > > > index 0000000000..320d7e929c
> > > > > --- /dev/null
> > > > > +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > > @@ -0,0 +1,125 @@
> > > > > +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> > > > > +From: Nick Desaulniers <ndesaulniers@google.com>
> > > > > +Date: Tue, 12 Jan 2021 11:46:24 -0800
> > > > > +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> > > > > +
> > > > > +Arnd found a randconfig that produces the warning:
> > > > > +
> > > > > +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> > > > > +  offset 0x3e
> > > > > +
> > > > > +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> > > > > +notes:
> > > > > +
> > > > > +  With the LLVM assembler not generating section symbols, objtool has no
> > > > > +  way to reference this code when it generates ORC unwinder entries,
> > > > > +  because this code is outside of any ELF function.
> > > > > +
> > > > > +  The limitation now being imposed by objtool is that all code must be
> > > > > +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> > > > > +
> > > > > +  So basically, you can use an .L symbol *inside* a function or a code
> > > > > +  segment, you just can't use the .L symbol to contain the code using a
> > > > > +  SYM_*_START/END annotation pair.
> > > > > +
> > > > > +Fangrui notes that this optimization is helpful for reducing image size
> > > > > +when compiling with -ffunction-sections and -fdata-sections. I have
> > > > > +observed on the order of tens of thousands of symbols for the kernel
> > > > > +images built with those flags.
> > > > > +
> > > > > +A patch has been authored against GNU binutils to match this behavior
> > > > > +of not generating unused section symbols ([1]), so this will
> > > > > +also become a problem for users of GNU binutils once they upgrade to 2.36.
> > > > > +
> > > > > +Omit the .L prefix on a label so that the assembler will emit an entry
> > > > > +into the symbol table for the label, with STB_LOCAL binding. This
> > > > > +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> > > > > +GNU binutils 2.36+.
> > > > > +
> > > > > + [ bp: Massage commit message. ]
> > > > > +
> > > > > +Reported-by: Arnd Bergmann <arnd@arndb.de>
> > > > > +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > +Suggested-by: Borislav Petkov <bp@alien8.de>
> > > > > +Suggested-by: Mark Brown <broonie@kernel.org>
> > > > > +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > > +Signed-off-by: Borislav Petkov <bp@suse.de>
> > > > > +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > > +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> > > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> > > > > +Link: https://reviews.llvm.org/D93783
> > > > > +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> > > > > +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> > > > > +---
> > > > > + Documentation/asm-annotations.rst | 5 +++++
> > > > > + arch/x86/entry/thunk_64.S         | 8 ++++----
> > > > > + include/linux/linkage.h           | 5 +++++
> > > > > + 3 files changed, 14 insertions(+), 4 deletions(-)
> > > > > +
> > > > > +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> > > > > +index 32ea57483378..76424e0431f4 100644
> > > > > +--- a/Documentation/asm-annotations.rst
> > > > > ++++ b/Documentation/asm-annotations.rst
> > > > > +@@ -100,6 +100,11 @@ Instruction Macros
> > > > > + ~~~~~~~~~~~~~~~~~~
> > > > > + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> > > > > +
> > > > > ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> > > > > ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> > > > > ++prefixed symbols can be used within a code region, but should be avoided for
> > > > > ++denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > > ++
> > > > > + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> > > > > +   most frequent markings**. They are used for functions with standard calling
> > > > > +   conventions -- global and local. Like in C, they both align the functions to
> > > > > +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> > > > > +index ccd32877a3c4..c9a9fbf1655f 100644
> > > > > +--- a/arch/x86/entry/thunk_64.S
> > > > > ++++ b/arch/x86/entry/thunk_64.S
> > > > > +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> > > > > +       .endif
> > > > > +
> > > > > +       call \func
> > > > > +-      jmp  .L_restore
> > > > > ++      jmp  __thunk_restore
> > > > > + SYM_FUNC_END(\name)
> > > > > +       _ASM_NOKPROBE(\name)
> > > > > +       .endm
> > > > > +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> > > > > + #endif
> > > > > +
> > > > > + #ifdef CONFIG_PREEMPTION
> > > > > +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > > ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> > > > > +       popq %r11
> > > > > +       popq %r10
> > > > > +       popq %r9
> > > > > +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > > +       popq %rdi
> > > > > +       popq %rbp
> > > > > +       ret
> > > > > +-      _ASM_NOKPROBE(.L_restore)
> > > > > +-SYM_CODE_END(.L_restore)
> > > > > ++      _ASM_NOKPROBE(__thunk_restore)
> > > > > ++SYM_CODE_END(__thunk_restore)
> > > > > + #endif
> > > > > +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> > > > > +index 5bcfbd972e97..dbf8506decca 100644
> > > > > +--- a/include/linux/linkage.h
> > > > > ++++ b/include/linux/linkage.h
> > > > > +@@ -178,6 +178,11 @@
> > > > > +  * Objtool generates debug info for both FUNC & CODE, but needs special
> > > > > +  * annotations for each CODE's start (to describe the actual stack frame).
> > > > > +  *
> > > > > ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> > > > > ++ * names that have a  .L prefix do not emit symbol table entries. .L
> > > > > ++ * prefixed symbols can be used within a code region, but should be avoided for
> > > > > ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > > ++ *
> > > > > +  * ALIAS -- does not generate debug info -- the aliased function will
> > > > > +  */
> > > > > +
> > > > > +--
> > > > > +2.30.0
> > > > > +
> > > > > diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > index 7e570b04f5..aa328aff52 100644
> > > > > --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
> > > > >  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
> > > > >             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
> > > > >
> > > > > +SRC_URI += "\
> > > > > +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> > > > > +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> > > > > +"
> > > > > +
> > > > >  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
> > > > >  LINUX_VERSION ?= "5.10.5"
> > > > >
> > > > > --
> > > > > 2.30.0
> > > > >
> > > > >
> > > > > 
> > > > >
> > > >
> > > >
> > > > --
> > > > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > > > thee at its end
> > > > - "Use the force Harry" - Gandalf, Star Trek II
>
>
>
> --
> - Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end
> - "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [OE-core] [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade
  2021-02-03  3:38           ` Khem Raj
@ 2021-02-03  3:43             ` Bruce Ashfield
  0 siblings, 0 replies; 11+ messages in thread
From: Bruce Ashfield @ 2021-02-03  3:43 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

On Tue, Feb 2, 2021 at 10:38 PM Khem Raj <raj.khem@gmail.com> wrote:
>
> I am not looking at 5.4 since the issue is x86 specific and all x86
> BSPs on master are already on 5.10 perhaps we wont need to backport it
> immediately

Yah. And I just tried to port the patches,
x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch was bad
enough, but I was manually able to do a reject resolution that looks
minimally sane .. but
objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch rejects in
every single file in the patch and they look non trivial to fix.

I'll keep watching for something on 5.4 -stable, but it will be tricky
to do it ourselves.

Bruce

>
> On Tue, Feb 2, 2021 at 7:29 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> >
> > On Tue, Feb 2, 2021 at 10:26 PM Khem Raj <raj.khem@gmail.com> wrote:
> > >
> > > ah I see your patch series, does this include above two patches ?
> >
> > It does yes.
> >
> > My local build worked, and since you confirmed they were good for the
> > binutils fix, I cherry picked them on that basis.
> >
> > I did notice that they failed to cherry-pick to v5.4 though, so if
> > want that to work with the new binutils, we have work to do, or wait
> > for -stable. Let me know if you are looking at it, otherwise, I'll see
> > what needs to be done tonight/tomorrow.
> >
> > Bruce
> >
> > >
> > > On Tue, Feb 2, 2021 at 7:18 PM Khem Raj <raj.khem@gmail.com> wrote:
> > > >
> > > > Hi Bruce
> > > >
> > > > Yeah :) it was my local series and as mentioned temp hack. I think we
> > > > will wait for your SRCREV bumps for final fix. but perhaps this can
> > > > help to temporarily testing master-next a bit.
> > > >
> > > > On Tue, Feb 2, 2021 at 7:12 PM Bruce Ashfield <bruce.ashfield@gmail.com> wrote:
> > > > >
> > > > > Richard,
> > > > >
> > > > > Obviously ignore this patch.
> > > > >
> > > > > It'll fail to apply as soon as my SRCREVs are bumped, and honestly,
> > > > > it's a hassle to have to wonder if this has been applied, have a
> > > > > failure, sent a revert, etc.
> > > > >
> > > > > I'm not even sure why it was sent.
> > > > >
> > > > > Bruce
> > > > >
> > > > > On Tue, Feb 2, 2021 at 8:36 PM Khem Raj <raj.khem@gmail.com> wrote:
> > > > > >
> > > > > > This is for master-next testing only !!
> > > > > >
> > > > > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > > > > ---
> > > > > >  ...fault-with-Clang-non-section-symbols.patch | 150 ++++++++++++++++++
> > > > > >  ...-symbol-for-register-restoring-thunk.patch | 125 +++++++++++++++
> > > > > >  meta/recipes-kernel/linux/linux-yocto_5.10.bb |   5 +
> > > > > >  3 files changed, 280 insertions(+)
> > > > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > > >  create mode 100644 meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > > >
> > > > > > diff --git a/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > > > new file mode 100644
> > > > > > index 0000000000..f606e3ee6d
> > > > > > --- /dev/null
> > > > > > +++ b/meta/recipes-kernel/linux/files/0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch
> > > > > > @@ -0,0 +1,150 @@
> > > > > > +From 44f6a7c0755d8dd453c70557e11687bb080a6f21 Mon Sep 17 00:00:00 2001
> > > > > > +From: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > > +Date: Mon, 14 Dec 2020 16:04:20 -0600
> > > > > > +Subject: [PATCH] objtool: Fix seg fault with Clang non-section symbols
> > > > > > +
> > > > > > +The Clang assembler likes to strip section symbols, which means objtool
> > > > > > +can't reference some text code by its section.  This confuses objtool
> > > > > > +greatly, causing it to seg fault.
> > > > > > +
> > > > > > +The fix is similar to what was done before, for ORC reloc generation:
> > > > > > +
> > > > > > +  e81e07244325 ("objtool: Support Clang non-section symbols in ORC generation")
> > > > > > +
> > > > > > +Factor out that code into a common helper and use it for static call
> > > > > > +reloc generation as well.
> > > > > > +
> > > > > > +Reported-by: Arnd Bergmann <arnd@kernel.org>
> > > > > > +Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > > +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > > > +Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > > > +Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> > > > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1207
> > > > > > +Link: https://lkml.kernel.org/r/ba6b6c0f0dd5acbba66e403955a967d9fdd1726a.1607983452.git.jpoimboe@redhat.com
> > > > > > +---
> > > > > > + tools/objtool/check.c   | 11 +++++++++--
> > > > > > + tools/objtool/elf.c     | 26 ++++++++++++++++++++++++++
> > > > > > + tools/objtool/elf.h     |  2 ++
> > > > > > + tools/objtool/orc_gen.c | 29 +++++------------------------
> > > > > > + 4 files changed, 42 insertions(+), 26 deletions(-)
> > > > > > +
> > > > > > +diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> > > > > > +index c6ab44543c92..5f8d3eed78a1 100644
> > > > > > +--- a/tools/objtool/check.c
> > > > > > ++++ b/tools/objtool/check.c
> > > > > > +@@ -467,13 +467,20 @@ static int create_static_call_sections(struct objtool_file *file)
> > > > > > +
> > > > > > +               /* populate reloc for 'addr' */
> > > > > > +               reloc = malloc(sizeof(*reloc));
> > > > > > ++
> > > > > > +               if (!reloc) {
> > > > > > +                       perror("malloc");
> > > > > > +                       return -1;
> > > > > > +               }
> > > > > > +               memset(reloc, 0, sizeof(*reloc));
> > > > > > +-              reloc->sym = insn->sec->sym;
> > > > > > +-              reloc->addend = insn->offset;
> > > > > > ++
> > > > > > ++              insn_to_reloc_sym_addend(insn->sec, insn->offset, reloc);
> > > > > > ++              if (!reloc->sym) {
> > > > > > ++                      WARN_FUNC("static call tramp: missing containing symbol",
> > > > > > ++                                insn->sec, insn->offset);
> > > > > > ++                      return -1;
> > > > > > ++              }
> > > > > > ++
> > > > > > +               reloc->type = R_X86_64_PC32;
> > > > > > +               reloc->offset = idx * sizeof(struct static_call_site);
> > > > > > +               reloc->sec = reloc_sec;
> > > > > > +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> > > > > > +index 4e1d7460574b..be89c741ba9a 100644
> > > > > > +--- a/tools/objtool/elf.c
> > > > > > ++++ b/tools/objtool/elf.c
> > > > > > +@@ -262,6 +262,32 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > > > +       return find_reloc_by_dest_range(elf, sec, offset, 1);
> > > > > > + }
> > > > > > +
> > > > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > > > ++                            struct reloc *reloc)
> > > > > > ++{
> > > > > > ++      if (sec->sym) {
> > > > > > ++              reloc->sym = sec->sym;
> > > > > > ++              reloc->addend = offset;
> > > > > > ++              return;
> > > > > > ++      }
> > > > > > ++
> > > > > > ++      /*
> > > > > > ++       * The Clang assembler strips section symbols, so we have to reference
> > > > > > ++       * the function symbol instead:
> > > > > > ++       */
> > > > > > ++      reloc->sym = find_symbol_containing(sec, offset);
> > > > > > ++      if (!reloc->sym) {
> > > > > > ++              /*
> > > > > > ++               * Hack alert.  This happens when we need to reference the NOP
> > > > > > ++               * pad insn immediately after the function.
> > > > > > ++               */
> > > > > > ++              reloc->sym = find_symbol_containing(sec, offset - 1);
> > > > > > ++      }
> > > > > > ++
> > > > > > ++      if (reloc->sym)
> > > > > > ++              reloc->addend = offset - reloc->sym->offset;
> > > > > > ++}
> > > > > > ++
> > > > > > + static int read_sections(struct elf *elf)
> > > > > > + {
> > > > > > +       Elf_Scn *s = NULL;
> > > > > > +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h
> > > > > > +index 807f8c670097..e6890cc70a25 100644
> > > > > > +--- a/tools/objtool/elf.h
> > > > > > ++++ b/tools/objtool/elf.h
> > > > > > +@@ -140,6 +140,8 @@ struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, uns
> > > > > > + struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
> > > > > > +                                    unsigned long offset, unsigned int len);
> > > > > > + struct symbol *find_func_containing(struct section *sec, unsigned long offset);
> > > > > > ++void insn_to_reloc_sym_addend(struct section *sec, unsigned long offset,
> > > > > > ++                            struct reloc *reloc);
> > > > > > + int elf_rebuild_reloc_section(struct elf *elf, struct section *sec);
> > > > > > +
> > > > > > + #define for_each_sec(file, sec)                                               \
> > > > > > +diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
> > > > > > +index 235663b96adc..9ce68b385a1b 100644
> > > > > > +--- a/tools/objtool/orc_gen.c
> > > > > > ++++ b/tools/objtool/orc_gen.c
> > > > > > +@@ -105,30 +105,11 @@ static int create_orc_entry(struct elf *elf, struct section *u_sec, struct secti
> > > > > > +       }
> > > > > > +       memset(reloc, 0, sizeof(*reloc));
> > > > > > +
> > > > > > +-      if (insn_sec->sym) {
> > > > > > +-              reloc->sym = insn_sec->sym;
> > > > > > +-              reloc->addend = insn_off;
> > > > > > +-      } else {
> > > > > > +-              /*
> > > > > > +-               * The Clang assembler doesn't produce section symbols, so we
> > > > > > +-               * have to reference the function symbol instead:
> > > > > > +-               */
> > > > > > +-              reloc->sym = find_symbol_containing(insn_sec, insn_off);
> > > > > > +-              if (!reloc->sym) {
> > > > > > +-                      /*
> > > > > > +-                       * Hack alert.  This happens when we need to reference
> > > > > > +-                       * the NOP pad insn immediately after the function.
> > > > > > +-                       */
> > > > > > +-                      reloc->sym = find_symbol_containing(insn_sec,
> > > > > > +-                                                         insn_off - 1);
> > > > > > +-              }
> > > > > > +-              if (!reloc->sym) {
> > > > > > +-                      WARN("missing symbol for insn at offset 0x%lx\n",
> > > > > > +-                           insn_off);
> > > > > > +-                      return -1;
> > > > > > +-              }
> > > > > > +-
> > > > > > +-              reloc->addend = insn_off - reloc->sym->offset;
> > > > > > ++      insn_to_reloc_sym_addend(insn_sec, insn_off, reloc);
> > > > > > ++      if (!reloc->sym) {
> > > > > > ++              WARN("missing symbol for insn at offset 0x%lx",
> > > > > > ++                   insn_off);
> > > > > > ++              return -1;
> > > > > > +       }
> > > > > > +
> > > > > > +       reloc->type = R_X86_64_PC32;
> > > > > > +--
> > > > > > +2.30.0
> > > > > > +
> > > > > > diff --git a/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > > > new file mode 100644
> > > > > > index 0000000000..320d7e929c
> > > > > > --- /dev/null
> > > > > > +++ b/meta/recipes-kernel/linux/files/0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch
> > > > > > @@ -0,0 +1,125 @@
> > > > > > +From de98d14b7f4511380a9d9b784a12507c790d8a54 Mon Sep 17 00:00:00 2001
> > > > > > +From: Nick Desaulniers <ndesaulniers@google.com>
> > > > > > +Date: Tue, 12 Jan 2021 11:46:24 -0800
> > > > > > +Subject: [PATCH] x86/entry: Emit a symbol for register restoring thunk
> > > > > > +
> > > > > > +Arnd found a randconfig that produces the warning:
> > > > > > +
> > > > > > +  arch/x86/entry/thunk_64.o: warning: objtool: missing symbol for insn at
> > > > > > +  offset 0x3e
> > > > > > +
> > > > > > +when building with LLVM_IAS=1 (Clang's integrated assembler). Josh
> > > > > > +notes:
> > > > > > +
> > > > > > +  With the LLVM assembler not generating section symbols, objtool has no
> > > > > > +  way to reference this code when it generates ORC unwinder entries,
> > > > > > +  because this code is outside of any ELF function.
> > > > > > +
> > > > > > +  The limitation now being imposed by objtool is that all code must be
> > > > > > +  contained in an ELF symbol.  And .L symbols don't create such symbols.
> > > > > > +
> > > > > > +  So basically, you can use an .L symbol *inside* a function or a code
> > > > > > +  segment, you just can't use the .L symbol to contain the code using a
> > > > > > +  SYM_*_START/END annotation pair.
> > > > > > +
> > > > > > +Fangrui notes that this optimization is helpful for reducing image size
> > > > > > +when compiling with -ffunction-sections and -fdata-sections. I have
> > > > > > +observed on the order of tens of thousands of symbols for the kernel
> > > > > > +images built with those flags.
> > > > > > +
> > > > > > +A patch has been authored against GNU binutils to match this behavior
> > > > > > +of not generating unused section symbols ([1]), so this will
> > > > > > +also become a problem for users of GNU binutils once they upgrade to 2.36.
> > > > > > +
> > > > > > +Omit the .L prefix on a label so that the assembler will emit an entry
> > > > > > +into the symbol table for the label, with STB_LOCAL binding. This
> > > > > > +enables objtool to generate proper unwind info here with LLVM_IAS=1 or
> > > > > > +GNU binutils 2.36+.
> > > > > > +
> > > > > > + [ bp: Massage commit message. ]
> > > > > > +
> > > > > > +Reported-by: Arnd Bergmann <arnd@arndb.de>
> > > > > > +Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > > +Suggested-by: Borislav Petkov <bp@alien8.de>
> > > > > > +Suggested-by: Mark Brown <broonie@kernel.org>
> > > > > > +Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> > > > > > +Signed-off-by: Borislav Petkov <bp@suse.de>
> > > > > > +Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > > > > > +Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
> > > > > > +Link: https://lkml.kernel.org/r/20210112194625.4181814-1-ndesaulniers@google.com
> > > > > > +Link: https://github.com/ClangBuiltLinux/linux/issues/1209
> > > > > > +Link: https://reviews.llvm.org/D93783
> > > > > > +Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html
> > > > > > +Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1408485ce69f844dcd7ded093a8 [1]
> > > > > > +---
> > > > > > + Documentation/asm-annotations.rst | 5 +++++
> > > > > > + arch/x86/entry/thunk_64.S         | 8 ++++----
> > > > > > + include/linux/linkage.h           | 5 +++++
> > > > > > + 3 files changed, 14 insertions(+), 4 deletions(-)
> > > > > > +
> > > > > > +diff --git a/Documentation/asm-annotations.rst b/Documentation/asm-annotations.rst
> > > > > > +index 32ea57483378..76424e0431f4 100644
> > > > > > +--- a/Documentation/asm-annotations.rst
> > > > > > ++++ b/Documentation/asm-annotations.rst
> > > > > > +@@ -100,6 +100,11 @@ Instruction Macros
> > > > > > + ~~~~~~~~~~~~~~~~~~
> > > > > > + This section covers ``SYM_FUNC_*`` and ``SYM_CODE_*`` enumerated above.
> > > > > > +
> > > > > > ++``objtool`` requires that all code must be contained in an ELF symbol. Symbol
> > > > > > ++names that have a ``.L`` prefix do not emit symbol table entries. ``.L``
> > > > > > ++prefixed symbols can be used within a code region, but should be avoided for
> > > > > > ++denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > > > ++
> > > > > > + * ``SYM_FUNC_START`` and ``SYM_FUNC_START_LOCAL`` are supposed to be **the
> > > > > > +   most frequent markings**. They are used for functions with standard calling
> > > > > > +   conventions -- global and local. Like in C, they both align the functions to
> > > > > > +diff --git a/arch/x86/entry/thunk_64.S b/arch/x86/entry/thunk_64.S
> > > > > > +index ccd32877a3c4..c9a9fbf1655f 100644
> > > > > > +--- a/arch/x86/entry/thunk_64.S
> > > > > > ++++ b/arch/x86/entry/thunk_64.S
> > > > > > +@@ -31,7 +31,7 @@ SYM_FUNC_START_NOALIGN(\name)
> > > > > > +       .endif
> > > > > > +
> > > > > > +       call \func
> > > > > > +-      jmp  .L_restore
> > > > > > ++      jmp  __thunk_restore
> > > > > > + SYM_FUNC_END(\name)
> > > > > > +       _ASM_NOKPROBE(\name)
> > > > > > +       .endm
> > > > > > +@@ -44,7 +44,7 @@ SYM_FUNC_END(\name)
> > > > > > + #endif
> > > > > > +
> > > > > > + #ifdef CONFIG_PREEMPTION
> > > > > > +-SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > > > ++SYM_CODE_START_LOCAL_NOALIGN(__thunk_restore)
> > > > > > +       popq %r11
> > > > > > +       popq %r10
> > > > > > +       popq %r9
> > > > > > +@@ -56,6 +56,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.L_restore)
> > > > > > +       popq %rdi
> > > > > > +       popq %rbp
> > > > > > +       ret
> > > > > > +-      _ASM_NOKPROBE(.L_restore)
> > > > > > +-SYM_CODE_END(.L_restore)
> > > > > > ++      _ASM_NOKPROBE(__thunk_restore)
> > > > > > ++SYM_CODE_END(__thunk_restore)
> > > > > > + #endif
> > > > > > +diff --git a/include/linux/linkage.h b/include/linux/linkage.h
> > > > > > +index 5bcfbd972e97..dbf8506decca 100644
> > > > > > +--- a/include/linux/linkage.h
> > > > > > ++++ b/include/linux/linkage.h
> > > > > > +@@ -178,6 +178,11 @@
> > > > > > +  * Objtool generates debug info for both FUNC & CODE, but needs special
> > > > > > +  * annotations for each CODE's start (to describe the actual stack frame).
> > > > > > +  *
> > > > > > ++ * Objtool requires that all code must be contained in an ELF symbol. Symbol
> > > > > > ++ * names that have a  .L prefix do not emit symbol table entries. .L
> > > > > > ++ * prefixed symbols can be used within a code region, but should be avoided for
> > > > > > ++ * denoting a range of code via ``SYM_*_START/END`` annotations.
> > > > > > ++ *
> > > > > > +  * ALIAS -- does not generate debug info -- the aliased function will
> > > > > > +  */
> > > > > > +
> > > > > > +--
> > > > > > +2.30.0
> > > > > > +
> > > > > > diff --git a/meta/recipes-kernel/linux/linux-yocto_5.10.bb b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > > index 7e570b04f5..aa328aff52 100644
> > > > > > --- a/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > > +++ b/meta/recipes-kernel/linux/linux-yocto_5.10.bb
> > > > > > @@ -29,6 +29,11 @@ SRCREV_meta ?= "47c7a3148a4d7653cec536ba202b25148d1952ad"
> > > > > >  SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \
> > > > > >             git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.10;destsuffix=${KMETA}"
> > > > > >
> > > > > > +SRC_URI += "\
> > > > > > +            file://0001-objtool-Fix-seg-fault-with-Clang-non-section-symbols.patch \
> > > > > > +            file://0001-x86-entry-Emit-a-symbol-for-register-restoring-thunk.patch \
> > > > > > +"
> > > > > > +
> > > > > >  LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46"
> > > > > >  LINUX_VERSION ?= "5.10.5"
> > > > > >
> > > > > > --
> > > > > > 2.30.0
> > > > > >
> > > > > >
> > > > > > 
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > > > > thee at its end
> > > > > - "Use the force Harry" - Gandalf, Star Trek II
> >
> >
> >
> > --
> > - Thou shalt not follow the NULL pointer, for chaos and madness await
> > thee at its end
> > - "Use the force Harry" - Gandalf, Star Trek II



-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-02-03  3:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03  1:36 [v2 1/5] binutils: Package libdep linker plugins Khem Raj
2021-02-03  1:36 ` [v2 2/5] binutils: Disable parallel install for target/nativesdk binutils Khem Raj
2021-02-03  1:36 ` [v2 3/5] glibc: Drop adding .file directive in asm files Khem Raj
2021-02-03  1:36 ` [v2 4/5] musl: " Khem Raj
2021-02-03  1:36 ` [v2 5/5] linux-yocto-5.10: Backport couple of patches for binutils 2.36 upgrade Khem Raj
2021-02-03  3:12   ` [OE-core] " Bruce Ashfield
2021-02-03  3:18     ` Khem Raj
2021-02-03  3:26       ` Khem Raj
2021-02-03  3:28         ` Bruce Ashfield
2021-02-03  3:38           ` Khem Raj
2021-02-03  3:43             ` Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.