[llvm] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 12:16:02 PST 2023
================
@@ -106,6 +111,79 @@ Error XCOFFDumper::dumpSections(ArrayRef<Shdr> Sections) {
return Error::success();
}
+static void
+dumpFileAuxSym(std::vector<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>> &AuxEntTbl,
+ XCOFF::CFileStringType Type, StringRef FileStr) {
+ XCOFFYAML::FileAuxEnt FileAuxSym;
+ FileAuxSym.FileNameOrString = FileStr;
+ FileAuxSym.FileStringType = Type;
+ AuxEntTbl.push_back(std::make_unique<XCOFFYAML::FileAuxEnt>(FileAuxSym));
+}
+
+static void
+dumpStatAuxSym(std::vector<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>> &AuxEntTbl,
+ const object::XCOFFSectAuxEntForStat &AuxEntPtr) {
+ XCOFFYAML::SectAuxEntForStat StatAuxSym;
+ StatAuxSym.SectionLength = AuxEntPtr.SectionLength;
+ StatAuxSym.NumberOfLineNum = AuxEntPtr.NumberOfLineNum;
+ StatAuxSym.NumberOfRelocEnt = AuxEntPtr.NumberOfRelocEnt;
+ AuxEntTbl.push_back(
----------------
diggerlin wrote:
how about to change all those dump*AuxSym into constructor function?
for example:
```
struct SectAuxEntForStat: AuxSymbolEnt {
.....
SectAuxEntForStat(object::XCOFFSectAuxEntForStat &AuxEntPtr)) : AuxSymbolEnt(AuxSymbolType::AUX_STAT) {
SectionLength = AuxEntPtr.SectionLength;
NumberOfLineNum = AuxEntPtr.NumberOfLineNum;
NumberOfRelocEnt = AuxEntPtr.NumberOfRelocEnt;
}
}
```
and than you do not need the function `dumpStatAuxSym` , you can use `AuxEntTbl.push_back()` where you call the `dumpStatAuxSym`
The suggestion will give some extra work, but I think it more reasonable.
https://github.com/llvm/llvm-project/pull/70642
More information about the llvm-commits
mailing list