[clang] [BPF] Relocate enumerators in case labels and add -fbpf-no-enum-reloc= (PR #243338)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 18 20:24:09 PST 2026
================
@@ -1658,6 +1682,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
<< CondExpr->getSourceRange();
}
+ // Check the relocated case values with their local values from here.
----------------
4ast wrote:
The error for the same enumerator twice is gone:
```c
case B:
return 3;
case B:
return 5;
```
Both labels get the same relocation, so they are equal on every kernel. The second label is never taken and clang is silent. With the attribute in `vmlinux.h` every prog loses this check.
I guess this is acceptable? Add to a doc.
https://github.com/llvm/llvm-project/pull/243338
More information about the cfe-commits
mailing list