[PATCH] D139516: [XCOFF] handle the toc-data for object file generation.
Esme Yi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 20:29:21 PST 2023
Esme added inline comments.
================
Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:2380
+ Name, Kind,
+ XCOFF::CsectProperties(XCOFF::XMC_TD, GO->isDeclarationForLinker()
+ ? XCOFF::XTY_ER
----------------
shchenz wrote:
> The caller of this function `SectionForGlobal` is not allowed to pass `external (or available externally) globals.`, So I don't think we need to care about XTY_ER type symbol here. See:
> ```
> /// This method computes the appropriate section to emit the specified global
> /// variable or function definition. This should not be passed external (or
> /// available externally) globals.
> MCSection *SectionForGlobal(const GlobalObject *GO, SectionKind Kind,
> const TargetMachine &TM) const;
> ```
>
> We should handle the section for external TD symbols in `getSectionForExternalReference()` and adjust the order when we create the symbol `TargetLoweringObjectFileXCOFF::getTargetSymbol()`, i.e., handle external symbol first.
Thanks, it makes sense more.
================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:638
FixedValue = TOCEntryOffset;
}
----------------
shchenz wrote:
> This must also be wrong now as for TOC direct external symbols, there will be no TOC slot for them, so the FiexedValue must always be 0. For example, for below case:
> ```
> int a = 20;
> extern int c;
> extern int b;
> int d = 10;
>
> int foo(void)
> {
> return a + b + c + d;
> }
> ```
>
> I get:
> ```
> 00000000 <.foo>:
> 0: 38 62 00 00 addi 3, 2, 0
> 00000002: R_TOC a
> 4: 38 82 ff ac addi 4, 2, -84
> 00000006: R_TOC b
> 8: 38 a2 ff ac addi 5, 2, -84
> 0000000a: R_TOC c
> c: 38 c2 00 04 addi 6, 2, 4
> 0000000e: R_TOC d
> ```
>
> a and d are correct, but b/c are obvious wrong.
It seems that the behavior of AIX's `as` is the same? So I'm a bit confused about this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139516/new/
https://reviews.llvm.org/D139516
More information about the llvm-commits
mailing list