[llvm] [llvm-symbolizer] Make symbolizer parse section relative syntax (PR #168524)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 03:05:09 PDT 2026


================
@@ -31,6 +35,24 @@
 
 # EMPTY-OFFSET: error: '(TEXT)()': section-relative offset "" must start with '+'
 
+## Test negative offset.
+# RUN: llvm-symbolizer --obj=%t.xcoff '(TEXT)(-0x10)' 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=NEG-OFFSET
+
+# NEG-OFFSET: error: '(TEXT)(-0x10)': section-relative offset "-0x10" must start with '+'
+
+## Test negative decimal offset.
+# RUN: llvm-symbolizer --obj=%t.xcoff '(TEXT)(-10)' 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=NEG-OFFSET-DEC
+
+# NEG-OFFSET-DEC: error: '(TEXT)(-10)': section-relative offset "-10" must start with '+'
+
+## Test offset with '+' followed by '-'.
+# RUN: llvm-symbolizer --obj=%t.xcoff '(TEXT)(+-0x10)' 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=PLUS-NEG
+
+# PLUS-NEG: error: '(TEXT)(+-0x10)': invalid offset "+-0x10" in section-relative address
----------------
jh7370 wrote:

Two things:

1) I don't think it's especially common to specify the full text of the option that is a problem (i.e. the `'(TEXT)(+-0x10)'` bit), especially given that the offending bit is mentioned in the text of the warning message.

2) Rather than repeating near-identical CHECK patterns for all of these different cases, you should be able to reduce the number of a smaller number by using FileCheck -D values.

Example:

```
# RUN:   FileCheck %s --check-prefix=INVALID-OFFSET -DOFFSET=+-0x10
# INVALID-OFFSET: error: invalid offset "[[OFFSET]]" in section-relative address
```

https://github.com/llvm/llvm-project/pull/168524


More information about the llvm-commits mailing list