diff options
author | Ross Burton <ross.burton@arm.com> | 2024-11-22 11:07:13 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-23 14:44:54 +0000 |
commit | e7d470c04fd1d817e26d0f684520c71b5a8047e5 (patch) | |
tree | 5427994167b3e9faa22780b86631688419a9bc83 | |
parent | 76c247d6f58c716f7e7759db7c2522f2379440ed (diff) | |
download | poky-e7d470c04fd1d817e26d0f684520c71b5a8047e5.tar.gz |
systemd: handle llvm-objcopy behaviour when reading .note.dlopen section
There are two behavioural differences between the objcopy in binutils
and llvm which resulted in build failures when building systemd with
clang:
1) If the section specified in --dump-section doesn't exist, binutils
set an exit code of 0 whereas llvm sets 1. This means we need to handle
the exit code so that we raise exceptions on unexpected failures, but
return an empty byte string if the segment isn't found.
2) binutils writes the section to the file name directly, whereas llvm
writes to a temporary file and renames. This means we can't read the
open fd directly, and instead need to re-open the file to read it.
(From OE-Core rev: 98879a8dbd1b7887b43a074193925bf1a55d44e7)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-core/systemd/dlopen-deps.inc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/meta/recipes-core/systemd/dlopen-deps.inc b/meta/recipes-core/systemd/dlopen-deps.inc index eaf6ca1f79..e0b333398c 100644 --- a/meta/recipes-core/systemd/dlopen-deps.inc +++ b/meta/recipes-core/systemd/dlopen-deps.inc | |||
@@ -12,9 +12,17 @@ python package_generate_dlopen_deps() { | |||
12 | import tempfile, subprocess | 12 | import tempfile, subprocess |
13 | 13 | ||
14 | with tempfile.NamedTemporaryFile() as f: | 14 | with tempfile.NamedTemporaryFile() as f: |
15 | cmd = [d.getVar("OBJCOPY"), "--dump-section", f"{segment}={f.name}", filename] | 15 | try: |
16 | subprocess.run(cmd, check=True) | 16 | cmd = [d.getVar("OBJCOPY"), "--dump-section", f"{segment}={f.name}", filename] |
17 | return f.read() | 17 | subprocess.run(cmd, check=True) |
18 | with open(f.name, "rb") as f2: | ||
19 | return f2.read() | ||
20 | except subprocess.CalledProcessError as e: | ||
21 | # binutils-objcopy has 0 exit code if the segment can't be found, but llvm-objcopy | ||
22 | # does not. Assume the failure isn't critical and ignore errors. | ||
23 | if e.returncode == 1: | ||
24 | return b"" | ||
25 | raise e | ||
18 | 26 | ||
19 | def parse(buffer, is_little): | 27 | def parse(buffer, is_little): |
20 | deps = [] | 28 | deps = [] |