I always regretted and disliked using yaml2obj. It works fine but honestly I prefer assembly. For ELF this means that program headers can't be tested inside of llvm since only the linker produces those. Early on I felt it critical to focus on fully linked executables and stripping them because that was the use case my team had at the time (and output to binary actually). It almost accidentally occurred that relocatable files were even supported. Today you could probably test the bulk of objcopy using the asembler and leave just a limited number of use cases to hand crafted ELF files and yaml2obj for when you're testing a valid ELF file that happens to have program headers. So my gut would be to say we should prefer using assembly to generate .o files rather than yaml2obj or uploading binaries we've built. Uploading binaries should be reserved for cases when both yaml2obj and assembly cannot produce a file that tickles the code you're trying to test which is almost always something that not even the linker can produce in my experience.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 29, 2018, 8:30 PM Alexander Shaposhnikov via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">alexshap marked an inline comment as done.<br>
alexshap added inline comments.<br>
<br>
<br>
================<br>
Comment at: test/tools/llvm-objcopy/MachO/basic-big-endian-32-copy.test:116<br>
+# CHECK: --- !mach-o<br>
+# CHECK: FileHeader:<br>
+# CHECK:  magic:           0xFEEDFACE<br>
----------------<br>
rupprecht wrote:<br>
> Can you also verify things coming from sections/symbol tables/etc? It seems this only tests that the FileHeader is preserved and everything else could be dropped...<br>
there is a problem with obj2yaml / yaml2obj - the support for MachO is incomplete, some things (like the content of the sections) are not dumped, maybe smth else is missing too. But in these tests (in this patch) where we copy the object files without modifications the real check is done on the line 3: cmp %t %t2, <br>
I've added FileCheck just to be sure that yaml2obj has done the right thing, but probably I should remove it here to avoid confusions.<br>
Regarding your other comment (about making use of llvm-readobj for tests) -<br>
yeah, I think llvm-readobj should work for some scenarios, although with llvm-readobj there is an issue - it doesn't print all the mach-o specific bits (i.e. all the load commands). <br>
So basically my proposal for this: in these tests cmp should be sufficient, later I will have to use yaml2obj & llvm-readobj to test the changes of the load commands, when I run into an issue that smth is not printed by the existing tools I will try to extend obj2yaml/llvm-readobj to support it. <br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D54674/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D54674/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D54674" rel="noreferrer" target="_blank">https://reviews.llvm.org/D54674</a><br>
<br>
<br>
<br>
</blockquote></div>