Add support for --dump-section on COFF files. This is helpful for
extracting specific content from an object file on Windows.
Details
- Reviewers
alexander-shaposhnikov jhenderson Unknown Object (User) hjyamauchi - Commits
- rG00e6d0e9ac5c: ObjCopy: support `--dump-section` on COFF
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
@hjyamauchi If you want to change username, I can help. Do you want to rename yamauchi to another name (which one?) and rename hjyamauchi to yamauchi?
There may also be ways to find passwords for yamauchi.
Requesting changes, just to stop this landing before my comments have been addressed. I don't see any serious issues, just a couple of stylistic things and some missing testing.
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp | ||
---|---|---|
135 | This doesn't look to conform to standard LLVM coding style. Please make sure you have run clang-format on your code. | |
152 | Please see the coding standards for errors and warning messages (use lower-case "s" for this message): https://llvm.org/docs/CodingStandards.html#error-and-warning-messages | |
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
1 | Please add the following two test cases: 1) the section does not exist; 2) the file cannot be created (e.g. because you're trying to create a file with the same path as an existing directory). Check that llvm-objcopy emits an error with the expected message in these cases. It may also be interesting to show that the contents of an existing file on disk are overwritten if it is the target of --dump-section. | |
16 | I'm not too familiar with coff yaml2obj, so my comments may not be applicable, but can you drop most of these sections from the YAML? I think you only need two sections (one empty and one non-empty). If possible, I'd even name those sections accordingly (i.e. something like ".empty" and ".nonempty"), and remove their characteristics, since they aren't relevant to the behaviour of llvm-objcopy. | |
42 | Similar to the above, if you can, please remove all the symbols (or at least the ones that aren't required). |
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp | ||
---|---|---|
135 | It does - it just is the older style :). Old habits die hard. I had avoided running it as it results in a lot of noise due to the removal, but I've run it and it does reflow this (and the other file - which is why I had avoided it. | |
152 | Probably should do the same in the ELF path :) | |
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
1 | Should probably add those to the ELF tests as well :) |
Hi Ray, thanks for the offer for help. I created the second account 'hjyamauchi' with the goal of integrating it with the login with my github account hjyamauchi@ and matching the github username and the phabricator username. Maybe that was my confusion around the github migration and it'd have been possible to switch an existing username/password-based account to a github login? I can log into both accounts. If possible, it might be best to rename 'yamauchi' to 'hjyamauchi' (and remove or rename the current 'hjyamauchi'), keep the review history from 'yamauchi' and integrate that with my github login.
Done! Matching the GitHub account is a good reason and I know others renaming for this reason.
Renamed to hjyamauchi to hjyamauchi-test and renamed yamauchi to hjyamauchi :)
@hjyamauchi contains all the contribution history (all occurrences of @yamauchi in old messages are replaced with @hjyamauchi).
If the result looks good, I can disable hjyamauchi-test so that people will not pick the wrong user.
(Like that I had @maskray0 which has been disabled.)
Thanks! I'll see how the new 'hjyamauchi' works out and let you know. I'll also see if I can integrate it with my github login.
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp | ||
---|---|---|
133 | +1 to SectionName and FileName. I think this nicely improves clarity. | |
152 | By all means do so (in a separate patch). I no longer directly work on LLVM, due to a change in job roles. I just review stuff :) | |
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
1 | Same comment as above :) | |
7–8 | Consistency fixes, and no need to ignore the case. Instead, use the %errc... substitutions, if needed (you might need to extend the list of available ones to cover the "is a directory" case). Also %T is considered deprecated (from the docs: "%T parent directory of %t (not unique, deprecated, do not use)"). You can use %S instead in this case. | |
14–16 | Could you check the full error message, please (less any tool name), using FileCheck -D to parameterise any file names. In particular, this will show that this is an error, and not a warning. |
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp | ||
---|---|---|
133 | +1 |
I'll make those adjustments and then commit - I'd like to get this through. I can address further feedback in follow ups as it seems most of the comments are about stylistic things at this point.
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
---|---|---|
7–8 | %T is the correct thing here; %S is the parent of the source which would write the file into the source tree. Creating a directory with %t is possible but annoying. | |
14–16 | Sure. |
I'll make those adjustments and then commit - I'd like to get this through. I can address further feedback in follow ups as it seems most of the comments are about stylistic things at this point.
What was the desperate rush about getting this landed without giving it at least 1 working day for other reviewers to have a final check through, especially when you actively disagreed with one of the requests?
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
---|---|---|
7–8 | The parent of the source will be a directory, which is all you're trying to achieve here. The docs state that using %T is deprecated. You shouldn't use it in new tests. Please address this point. It looks like you didn't adopt my inline request to use double-dash for --check-prefix: as things stand, you've got FileCheck commands in this test using both single and double-dash (I'm pretty sure double-dash is preferred everwhere). | |
14–16 | This comment was meant to apply to both error cases: please update CHECK-NO-SECTION too. |
llvm/test/tools/llvm-objcopy/COFF/dump-section.test | ||
---|---|---|
7–8 | I agree that %T should be avoided. If another test in .../COFF/ does something with %T, this will easily cause a race condition. If a test file creates a lot of temporary files, sometimes # RUN: rm -rf %t && mkdir %t && cd %t is easier. --check-prefix= is the most common form. -check-prefix= is less recommended but common as well. |
Hi Ray, I see that the 'hjyamauchi-test' account is already disabled and I cannot log into it anymore. That's fine but would you be able to move the email address associated with the disabled account to the 'hjyamauchi' account (or give it a bonus address, or swap the two gmail accounts in those accounts if an empty address isn't allowed in a disabled account, or delete the disabled account completely so that I can use the address in the 'hjyamauchi' account)? The system doesn't let me do so because the address appears to be still associated with the disabled account. I was going to do this swap on my own earlier but failed to do so yet. Thanks for your help!
nit: "S" -> "Section" to match "File"?