This is an archive of the discontinued LLVM Phabricator instance.

[AIX] llvm-nm support environment "OBJECT_MODE" for option -X on AIX OS
ClosedPublic

Authored by DiggerLin on Aug 23 2022, 12:16 PM.

Details

Summary

according nm in AIX OS , https://www.ibm.com/docs/en/aix/7.2?topic=n-nm-command

In AIX OS, The default is to process 32-bit object files (ignore 64-bit objects). The mode can also be set with the OBJECT_MODE environment variable. For example, OBJECT_MODE=64 causes nm to process any 64-bit objects and ignore 32-bit objects. The -X flag overrides the OBJECT_MODE variable.

In non AIX OS. The default is to process all support object files. and not support the OBJECT_MODE environment variable.

Diff Detail

Event Timeline

DiggerLin created this revision.Aug 23 2022, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 12:16 PM
DiggerLin requested review of this revision.Aug 23 2022, 12:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 12:16 PM
DiggerLin retitled this revision from [AIX] llvm-nm support environment "OBJECT_MODE" on AIX OS to [AIX] llvm-nm support environment "OBJECT_MODE" for option -X on AIX OS.
DiggerLin edited the summary of this revision. (Show Details)
jhenderson added inline comments.Aug 26 2022, 12:59 AM
llvm/docs/CommandGuide/llvm-nm.rst
144–150

Some suggested rewording.

Please reflow all lines to an 80 character width.

llvm/test/tools/llvm-nm/option-X-AIX.test
23
28–30

You should specify a different OBJECT_MODE value here instead of any, since otherwise you aren't actually showing the overriding behaviour. Perhaps use 32 for these two cases?

43–44

Is there a reason you're using bitcode files for the first set of tests and XCOFF files here? It seems like you could just use one set of files for all the testing.

48

Like you have above, please add comments describing the test cases.

68–71

In the first half of your test, with the bitcode files and no archive, you share the same set of prefixes for your 32 + 64 cases with your "both" cases. I don't see why this half of your test should be any different. I think the first half of the test flows quite smoothly, so I suggest reorganising this half accordingly.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
4
25–26

There's no need to have the ELF, bitcode, XCOFF and archive cases in separate llvm-nm invocations - they can all be one llvm-nm call.

llvm/tools/llvm-nm/llvm-nm.cpp
2380

The lambda doesn't add anything, since it's only called once.

DiggerLin updated this revision to Diff 457374.Sep 1 2022, 1:17 PM
DiggerLin marked 9 inline comments as done.

address comment

llvm/docs/CommandGuide/llvm-nm.rst
144–150

thanks

llvm/test/tools/llvm-nm/option-X-AIX.test
43–44

there is no reason to using bitcode files for the first set of tests. I chose the bit code and XCOFF just because the format are used in AIX OS. other object file format are not used in AIX OS.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
25–26

I combine ELF, bitcode, XCOFF together , and put archive in separate test, otherwise the test is too complication.

llvm/tools/llvm-nm/llvm-nm.cpp
2380

thanks

jhenderson added inline comments.Sep 2 2022, 1:27 AM
llvm/docs/CommandGuide/llvm-nm.rst
144
150–151

Slight tweak from my earlier suggestion, on second reading.

llvm/test/tools/llvm-nm/option-X-AIX.test
43–44

I guess my point is that you don't need both XCOFF and bitcode inputs. You could just have one file format for this test's purposes.

63
68–71

I don't think you fully understood my comment. In the first half of the test (where you are testing bitcode), you have only two prefixes, one for 32-bit and one for 64-bit files. The case where you expect both to be output is then tested using --check-prefixes with both prefixes specified. However, for archives, you have a total of 5 different prefixes: ARC32, ARC64, XCOFF32, XCOFF64 and BOTH. I think you can drop the BOTH case by simply specifying --check-prefixes=ARC32,ARC64,XCOFF32,XCOFF64.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
2

I've taken another look at this test and am wondering what the test gives us above what regular llvm-nm tests give us?

DiggerLin updated this revision to Diff 458507.Sep 7 2022, 10:38 AM
DiggerLin marked 3 inline comments as done.

address comment

llvm/test/tools/llvm-nm/option-X-AIX.test
63

I think we do not need to test the archive here.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
2

the default behavior of llvm-nm is different of AIX os and on Non-AIX os.

If in Non-AIX OS , if there is no -X option in llvm-nm command the default value of -X is any bits. (and the Non-AIX also ignore the OBJECT_MODE environment).

but for the AIX OS. if there is no -X option in llvm-nm command the default value of -X is 32 bits(if there is no OBJECT_MODE environment).

so we need separate test case to test the default value of -X in Non-AIX os.

jhenderson added inline comments.Sep 8 2022, 12:20 AM
llvm/test/tools/llvm-nm/option-X-AIX.test
63

I'd recommend we have some sort of archive testing + -X.OBJECT_MODE in llvm-nm tests. Archives are a different enough case internally that even though it may share code ultimately, it's a good idea to check them anyway.

You don't need to test every combination of the environment variable + -X with archives: it would be sufficient (if it doesn't already exist) to show that one or other works with archives when using llvm-nm.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
2

I think there's definitely value in showing that OBJECT_MODE is ignored on non-AIX, so the second half of this test is useful and should be kept. The first half is not doing anything that other llvm-nm testing won't alreday do: those tests on non-AIX should have coverage for 32 and 64-bit objects and show that they are dumped as expected when requested. We know from the second half of this test that the OBJECT_MODLE=any setting in the test config is ignored, so we don't need to worry about it overriding the default behaviour. Therefore, we can see that the default behaviour is to recognise 32 and 64-bit objects, from those tests.

17

No need to repeat this comment twice: probably delete the earlier instance above the YAML.

21
DiggerLin updated this revision to Diff 459732.Sep 13 2022, 6:27 AM
DiggerLin marked 4 inline comments as done.

address comment

DiggerLin added inline comments.Sep 13 2022, 6:49 AM
llvm/test/tools/llvm-nm/option-X-Non-AIX.test
2

agree, thanks

jhenderson accepted this revision.Sep 14 2022, 12:55 AM

LGTM, with one nit.

llvm/test/tools/llvm-nm/option-X-Non-AIX.test
15

Nit: this line has a trailing space. Please delete it.

This revision is now accepted and ready to land.Sep 14 2022, 12:55 AM