[PATCH] D82536: [AVR] Use correct relocation for function pointers in globals
Jake Goulding via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 07:03:23 PDT 2020
shepmaster added inline comments.
================
Comment at: llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp:74
+ auto &symbol = cast<MCSymbolELF>(Target.getSymA()->getSymbol());
+ if (symbol.getType() == ELF::STT_NOTYPE)
+ // Not a global variable, so probably a function pointer.
----------------
Running this patch with my original code, it still doesn't work. If I print out `symbol.getType()`, it's 2, which seems to be `STT_FUNC`:
```
enum {
STT_NOTYPE = 0, // Symbol's type is not specified
STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.)
STT_FUNC = 2, // Symbol is executable code (function, etc.)
```
I changed it to include both:
```
- if (symbol.getType() == ELF::STT_NOTYPE)
+ auto type = symbol.getType();
+ if (type == ELF::STT_NOTYPE || type == ELF::STT_FUNC)
```
And this allowed my code to work.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82536/new/
https://reviews.llvm.org/D82536
More information about the llvm-commits
mailing list