This patch adds yaml2obj supporting for the auxiliary file header of XCOFF.
Details
- Reviewers
jhenderson DiggerLin shchenz jsji qiucf Higuoxing - Group Reviewers
Restricted Project - Commits
- rGab97ffb96add: Reland [XCOFF][yaml2obj] support for the auxiliary file header.
rGe1eec7601b69: [XCOFF][yaml2obj] support for the auxiliary file header.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/ObjectYAML/XCOFFEmitter.cpp | ||
---|---|---|
245–246 | ||
250–251 | I just remembered that llvm::Optional has a getValueOr(T Value) function which gives you the input parameter, if the optional is none, or the stored value otherwise. I think that would make the code throughout much simpler. | |
348 | Do you actually need the casts? You've explicitly specified the type for write after all. If you do need a cast, use static_cast. | |
466 | Give the 32768 magic number a name, i.e. put it in a variable or constant somewhere. Flags are also usually written as hex in the source code, which might help make things clearer. | |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-32.yaml | ||
8 ↗ | (On Diff #378567) | This and the 64-bit test need to show that the value isn't taken from the sections if present, i.e. they need to have at least one section of each type with values different to the explicitly specified values in the YAML. |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
1 ↗ | (On Diff #378567) | I think you need a 32-bit and 64-bit version of this test. In other words, show what the default is for both formats. Does that make sense to you? I think you also need to show what happens when there are no text/data/bss sections etc from which to derive the values if not specified. |
8 ↗ | (On Diff #378567) | I might be being dumb, but the sizes below look like 2 bytes to me. |
47 ↗ | (On Diff #378567) | Assuming that a single section contributes to the field, you should use a different size here, to show that the right one is picked. |
48–49 ↗ | (On Diff #378567) | Don't you need duplicates of this and some of the other sections, like .text, to show that the first one wins in all cases? |
llvm/lib/ObjectYAML/XCOFFEmitter.cpp | ||
---|---|---|
250–251 | Thanks! | |
348 | The casts were necessary in the comparison expressions. | |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
1 ↗ | (On Diff #378567) | Yes! The suggestions make sense to me. Thanks! |
8 ↗ | (On Diff #378567) | Because the DefaultSectionAlign is 4 in XCOFF. |
llvm/lib/ObjectYAML/XCOFFEmitter.cpp | ||
---|---|---|
375 | should be yaml::Hex8(0) for flag. | |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
69 ↗ | (On Diff #380586) | in the xcoff document , some section are not multi section allow. https://www.ibm.com/docs/en/aix/7.2?topic=formats-xcoff-object-file-format#XCOFF__a2zjvh2b9shar |
llvm/lib/ObjectYAML/XCOFFEmitter.cpp | ||
---|---|---|
351–352 | I might put the comment on the same line, because it's a little confusing whether it's referring to just this one field or not. | |
375 | Just checking: should this comment be CPU rather than CUP? | |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-full-contents.yaml | ||
92–95 | These numbers aren't obviously arbitrary, I'd suggest making them more obviously so, e.g. 0x1111, 0x2222 etc. | |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
1 ↗ | (On Diff #380586) | Perhaps rename the test to aux-hdr-defaults.yaml. |
50 ↗ | (On Diff #380586) | Probably fill with non-zero values all the way. Maybe also add a comment why you have two of each section. |
69 ↗ | (On Diff #380586) | Remember, this is yaml2obj, so we should be as flexible as possible. |
74 ↗ | (On Diff #380586) | Same below. I wonder if you could reuse most of the FileCheck data here with the 32-bit case, rather than duplicating it? I've not looked too closely, but perhaps multiple check-prefixes would be appropriate, e.g. --check-prefixes=COMMON1,CASE1-64? |
113 ↗ | (On Diff #380586) | |
8 ↗ | (On Diff #378567) | So in XCOFF are sections tail padded? In ELF, there are just unlabelled gaps between sections, if alignment padding is required. |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
---|---|---|
74 ↗ | (On Diff #380586) | the data members and the order the data members of auxiliary header between 32bit and 64bit are different , if using COMMON1,CASE1-64 , I think it maybe more difficult to read the test case. |
Address comments.
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-omit.yaml | ||
---|---|---|
50 ↗ | (On Diff #380586) | I think setting section content with non-zero values is enough since the size and address will be derived automatically. |
74 ↗ | (On Diff #380586) | Thanks for your comments and agree with Digger to keep the current check-style. |
8 ↗ | (On Diff #378567) | Yes, it's required that the section address aligned to DefaultSectionAlign. |
llvm/test/tools/yaml2obj/XCOFF/aux-hdr-defaults.yaml | ||
---|---|---|
18 | Yes, it sounds reasonable to me. |
llvm/lib/ObjectYAML/XCOFFEmitter.cpp | ||
---|---|---|
356 | This is failing on MSVC builds: E:\llvm\llvm-project\llvm\include\llvm/ADT/Optional.h(298): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called E:\llvm\llvm-project\llvm\lib\ObjectYAML\XCOFFEmitter.cpp(356): note: see reference to function template instantiation 'T llvm::Optional<T>::getValueOr<llvm::yaml::Hex32>(U &&) const &' being compiled with [ T=llvm::yaml::Hex64, U=llvm::yaml::Hex32 ] |