[llvm] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 02:06:01 PST 2023
================
@@ -282,45 +282,53 @@ static void auxSymMapping(IO &IO, XCOFFYAML::SectAuxEntForStat &AuxSym) {
void MappingTraits<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>>::mapping(
IO &IO, std::unique_ptr<XCOFFYAML::AuxSymbolEnt> &AuxSym) {
- assert(!IO.outputting() && "We don't dump aux symbols currently.");
+
+ auto ResetAuxSym = [&](auto *AuxEnt) {
+ if (!IO.outputting())
+ AuxSym.reset(AuxEnt);
+ };
+
const bool Is64 =
static_cast<XCOFFYAML::Object *>(IO.getContext())->Header.Magic ==
(llvm::yaml::Hex16)XCOFF::XCOFF64;
+
XCOFFYAML::AuxSymbolType AuxType;
+ if (IO.outputting())
+ AuxType = AuxSym.get()->Type;
IO.mapRequired("Type", AuxType);
switch (AuxType) {
case XCOFFYAML::AUX_EXCEPT:
if (!Is64)
IO.setError("an auxiliary symbol of type AUX_EXCEPT cannot be defined in "
"XCOFF32");
- AuxSym.reset(new XCOFFYAML::ExcpetionAuxEnt());
+ ResetAuxSym(new XCOFFYAML::ExcpetionAuxEnt());
----------------
EsmeYi wrote:
The yaml2obj fails to parse immediately once the IO.setError() triggered and the error message is printed directly, therefore we don't need an `else` here.
https://github.com/llvm/llvm-project/pull/70642
More information about the llvm-commits
mailing list