Nathan Chancellor
4ae191effb
kbuild: Fix changing ELF file type for output of gen_btf for big endian
...
commit e3a9ee963ad8ba677ca925149812c5932b49af69 upstream.
Commit 90ceddcb4950 ("bpf: Support llvm-objcopy for vmlinux BTF")
changed the ELF type of .btf.vmlinux.bin.o to ET_REL via dd, which works
fine for little endian platforms:
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
-00000010 03 00 b7 00 01 00 00 00 00 00 00 80 00 80 ff ff |................|
+00000010 01 00 b7 00 01 00 00 00 00 00 00 80 00 80 ff ff |................|
However, for big endian platforms, it changes the wrong byte, resulting
in an invalid ELF file type, which ld.lld rejects:
00000000 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
-00000010 00 03 00 16 00 00 00 01 00 00 00 00 00 10 00 00 |................|
+00000010 01 03 00 16 00 00 00 01 00 00 00 00 00 10 00 00 |................|
Type: <unknown>: 103
ld.lld: error: .btf.vmlinux.bin.o: unknown file type
Fix this by updating the entire 16-bit e_type field rather than just a
single byte, so that everything works correctly for all platforms and
linkers.
00000000 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 |.ELF............|
-00000010 00 03 00 16 00 00 00 01 00 00 00 00 00 10 00 00 |................|
+00000010 00 01 00 16 00 00 00 01 00 00 00 00 00 10 00 00 |................|
Type: REL (Relocatable file)
While in the area, update the comment to mention that binutils 2.35+
matches LLD's behavior of rejecting an ET_EXEC input, which occurred
after the comment was added.
Cc: stable@vger.kernel.org
Fixes: 90ceddcb4950 ("bpf: Support llvm-objcopy for vmlinux BTF")
Link: https://github.com/llvm/llvm-project/pull/75643
Suggested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
[nathan: Fix silent conflict due to lack of 7d153696e5db in older trees]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-02-23 08:25:10 +01:00
..
2019-06-25 10:17:07 +02:00
2019-08-29 23:54:29 +09:00
2020-08-11 15:33:35 +02:00
2022-01-27 09:19:55 +01:00
2023-11-28 16:50:17 +00:00
2023-05-17 11:35:55 +02:00
2019-09-14 11:40:13 +09:00
2023-12-13 18:18:10 +01:00
2023-11-20 10:30:14 +01:00
2020-09-03 11:27:10 +02:00
2022-10-26 13:22:21 +02:00
2023-02-06 07:52:44 +01:00
2018-12-22 00:37:52 +09:00
2019-07-18 02:19:31 +09:00
2023-04-26 11:24:06 +02:00
2018-07-18 01:18:05 +09:00
2021-05-22 11:38:30 +02:00
2019-06-05 17:37:11 +02:00
2019-05-13 01:12:45 +02:00
2018-06-28 13:36:39 +09:00
2019-05-30 11:26:39 -07:00
2020-12-30 11:51:27 +01:00
2019-06-05 02:33:10 +09:00
2019-02-19 21:27:53 +01:00
2019-03-04 22:34:54 +09:00
2018-08-14 08:58:56 +09:00
2021-05-22 11:38:30 +02:00
2019-05-24 17:36:42 +02:00
2020-07-29 10:18:35 +02:00
2020-05-14 07:58:29 +02:00
2021-01-12 20:16:10 +01:00
2021-05-22 11:38:30 +02:00
2019-06-14 14:43:01 -06:00
2020-03-25 08:25:55 +01:00
2019-06-05 17:37:07 +02:00
2022-11-25 17:42:10 +01:00
2019-06-05 17:37:10 +02:00
2022-12-08 11:23:02 +01:00
2020-02-11 04:35:23 -08:00
2019-01-06 09:46:51 +09:00
2019-03-04 22:35:04 +09:00
2018-06-08 18:56:00 +09:00
2018-06-25 23:21:13 +09:00
2019-07-27 12:18:19 +09:00
2021-09-22 12:26:26 +02:00
2021-05-22 11:38:30 +02:00
2019-05-24 17:36:45 +02:00
2019-07-16 19:23:22 -07:00
2019-05-30 11:26:39 -07:00
2020-06-24 17:50:33 +02:00
2020-01-04 19:18:23 +01:00
2022-10-26 13:22:46 +02:00
2020-04-08 09:08:37 +02:00
2019-08-12 15:00:37 -06:00
2021-11-17 09:48:31 +01:00
2024-02-23 08:25:10 +01:00
2021-02-26 10:10:27 +01:00
2019-03-17 12:56:32 +09:00
2021-07-14 16:53:20 +02:00
2019-08-29 23:54:29 +09:00
2022-10-07 09:16:57 +02:00
2022-08-25 11:18:31 +02:00
2020-03-05 16:43:47 +01:00
2019-09-04 23:12:50 +09:00
2019-08-15 13:24:04 +01:00
2019-05-21 10:50:46 +02:00
2020-09-03 11:27:10 +02:00
2019-07-17 22:39:27 +09:00
2019-08-22 01:14:11 +09:00
2019-07-17 22:39:27 +09:00
2022-09-05 10:27:45 +02:00
2019-07-17 22:39:27 +09:00
2020-09-03 11:27:10 +02:00
2019-05-06 11:12:09 -07:00
2019-06-05 17:37:10 +02:00
2021-07-25 14:35:12 +02:00
2019-08-29 23:54:29 +09:00
2022-09-28 11:03:59 +02:00
2019-07-17 22:39:27 +09:00
2019-10-05 15:29:49 +09:00
2020-08-11 15:33:35 +02:00
2019-05-30 11:29:23 -07:00
2020-03-25 08:25:49 +01:00
2023-05-30 12:44:04 +01:00
2021-06-30 08:47:49 -04:00
2022-01-05 12:37:44 +01:00
2020-11-01 12:01:01 +01:00
2021-05-22 11:38:30 +02:00
2023-12-20 15:41:17 +01:00
2019-06-05 17:37:10 +02:00
2019-06-05 17:37:10 +02:00
2018-12-28 12:11:44 -08:00
2019-06-01 15:51:31 -07:00
2019-07-12 11:05:41 -07:00
2021-05-22 11:38:30 +02:00
2021-05-22 11:38:30 +02:00
2018-09-05 08:12:09 -06:00
2023-07-27 08:37:03 +02:00
2021-07-14 16:53:12 +02:00
2018-11-30 14:45:01 -08:00
2019-01-22 13:34:35 +01:00
2020-09-03 11:27:10 +02:00