[llvm] [ObjectYAML][ELF] Report incorrect offset to generate notes (PR #118741)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 00:33:25 PST 2024
================
@@ -514,3 +514,58 @@ Sections:
Desc: 030405
- Name: GNU
Type: NT_GNU_BUILD_ID
+
+## Check that an incorrect offset for generating notes is reported.
+
+# RUN: not yaml2obj --docnum=19 %s 2>&1 | FileCheck %s --check-prefix=ERR_OFFSET
+# ERR_OFFSET: error: .note: invalid offset of a note section: 0x{{.*}}, should be aligned to 4
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+Sections:
+ - Name: .dummy
+ Type: SHT_PROGBITS
+ Size: 1
+ - Name: .note
+ Type: SHT_NOTE
+ Notes:
----------------
jh7370 wrote:
It's not strictly required, but I think it might be helpful if you explicitly hard-coded the offset to some reasonable value (e.g. 0x501). This has two benefits:
1) It calls out the offset value as being important.
2) You can check the exact offset value in the error message.
https://github.com/llvm/llvm-project/pull/118741
More information about the llvm-commits
mailing list