- Expanded testing for export-dynamic and dynamic list
- Added cases that have no matching symbol
- Added uses of fatal-warnings to ensure warnings are not output unexpectedly
- Rename dynamic-list-wildcard.s to dynamic-list-patterns.s and expanded the test
- Added export-symbol-types.s
- Fixed invalid-dynamic-list, previously the same list was used in each case. When looking at this test on I found that the 5th case was failing to echo successfully leading to the previous case being tested again.
- Allow invalid-dynamic-list to run on Windows after removing the use of echo with quoted strings.
Details
Diff Detail
Event Timeline
Interesting. Oh, did you know that I have an ongoing discussion with binutils to refine the semantics of --export-dynamic-symbol --dynamic-symbol -Bsymbolic :) https://sourceware.org/pipermail/binutils/2020-May/111019.html
Generally LG. Few comments below.
lld/test/ELF/export-dynamic-symbol.s | ||
---|---|---|
8–10 | ## | |
9 | A double space after --fatal-warnings (and below). | |
lld/test/ELF/export-symbol-types.s | ||
2 | It probably missing a description of what this test case generally checks. | |
18 | export-symbol-types.s is short. Could you use echo instead? | |
22 | ## Also, full stop is missing. | |
24 | This empty line looks excessive. |
Changes based on grimars comments:
- Corrected white space and comments
- Replaced the use of input file "Inputs/export-symbol-types.s" with use of echo
lld/test/ELF/dynamic-list-patterns.s | ||
---|---|---|
8 | -unknown-linux can be dropped (this tests generic ELF behavior) | |
10 | Use ' for outermost quotes | |
12 | --dyn-syms You can also use llvm-nm -D | |
lld/test/ELF/export-symbol-types.s | ||
32 | --dyn-syms | |
33 | Can you find existing tests which can be deleted after you add the more comprehensive test here? |
Changes based on MaskRay's comments:
- Replace use of --dyn-symbols with --dynsyms
- Remove use of -unknown-linux
- Correct use of quotes
lld/test/ELF/dynamic-list-patterns.s | ||
---|---|---|
12 | The other tests use llvm-readelf so thought it best to be consistent, also I think confirming the number of entries is easier with readelf. If llvm-nm is preferred I could update the other tests too? | |
lld/test/ELF/export-symbol-types.s | ||
33 | I had a look at the other tests for --dynamic-list and --export-dynamic and believe they each add coverage e.g. they test for a particular error message or are case when multiple symbols of the same type are exported together etc. If there is a test you have in mind I could add it to the review. |
--dynamic-list is an obscure option. I just wondered how you get interested in it:)
There are fuzzy things about its semantics and relationship with -Bsymbolic, --export-dynamic, etc. That was the motivation behind my GNU ld patches.
I hope they can accept reasonable order-independent semantics.
https://sourceware.org/pipermail/binutils/2020-May/111211.html (I am happy with our our --dynamic-list semantics)
https://sourceware.org/pipermail/binutils/2020-May/111019.html (we may need to change --export-dynamic-symbol a bit)
lld/test/ELF/export-symbol-types.s | ||
---|---|---|
3 | For -shared, --dynamic-list does not affect the exported symbols. |
lld/test/ELF/export-symbol-types.s | ||
---|---|---|
4 | I think the test should be named dynamic-list-* instead, instead of export-symbol --dynamic-list work for both executables and shared libraries. We should check both executable and so cases. |
Created D80487 for --export-dynamic-symbol
lld/test/ELF/Inputs/invalid-dynamic-list-1.list | ||
---|---|---|
1 | echo '.........' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o for simple tests | |
lld/test/ELF/export-symbol-types.s | ||
1 | REQUIRES: x86 The test duplicates partially with dynsym-pie.s, symbols.s and visibility.s Check if they can be reorganized. | |
11 | imported symbols -> shared symbols | |
18 | echo '{ *; };' > %t.list | |
20 | write on one line and separate statements with ; | |
24 | Use the same basename for .o and .so if applicable | |
36 | Just use CHECK-NEXT: The diagnostic will be better if things go off. This does rely on the symbol table order and will require extra efforts when the order does change, but I think the cost pays off. | |
38 | Use ABS for abs | |
43 | technically this is not referenced. You may name it undef_weak (yes, the order undefined weak (instead of weak undefined) is used in the ELF spec) |
Made the following changes:
- Fixed up a comment
- Added x86 requirement
- Changed the creation of the dynamic list in export-symbol-types.s
- Made file names more consistent
- Use CHECK-NEXT
- Use ABS for abs
- rename symbol
Thanks for the comments Maskray. I had some questions regarding the comments for expanding the test for use of -shared and the similarities with dynsym-pie.s, symbols.s and visibility.s. My intention with the test export-symbol-types.s was to confirm the symbols types that are placed in the dynamic symbol table with use of --export-dynamic and --dynamic-list. I considered the other tests mentioned as covering related but different functionality using similar methods. For example symbol.s being for correct symbol output as a whole, not specifically exports etc.
I can see there being a reason to expand the coverage of the existing test to cover -shared, this would require the rename and potentially splitting the existing test in two. It may also be worth creating one input assembly file that can be used for all these tests mentioned to ensure coverage. Could this wait for a future change however?
Also, with your comment were you suggesting removing some of the existing tests and folding them into the one added here? As they test different functionality I think it may be best to keep them separate.
lld/test/ELF/dynamic-list-patterns.s | ||
---|---|---|
2 | dynamic-list-glob.s may be better. The recognized patterns are globs, not regex. | |
4 | Thanks for deleting dynamic-list-wildcard.s Whether an entry is a glob depends on whether double quotes are used. It is not unconditional glob, so the sentence is not accurate.
| |
11 | s/%t.elf/%t/ | |
lld/test/ELF/export-dynamic-symbol.s | ||
3 | I committed D80487 which came with a bunch of tests. These cases should have been covered. | |
lld/test/ELF/export-symbol-types.s | ||
10 | undefined symbols and shared symbols are exported. --export-dynamic, --dynamic-list and --export-dynamic-symbol can export additional symbols: non-local STV_DEFAULT symbols The list is not accurate because there is overlap between hidden symbols and weak symbols, for example. weak symbols are not unconditionally exported. Many symbols generated by the linker are not exported (hidden). | |
25 | Drop -shared. .so obviously identifies a shared object. | |
27 | Drop -elf. It carries no additional information. All object files discussed here are ELF. | |
27 | Delete llvm-mc -filetype=obj -triple=x86_64 %s -o %t-elf.o the object file is the same | |
lld/test/ELF/invalid-dynamic-list.test | ||
5–6 | You can update the quotes by the way. |
I carefully checked. export-symbol-types.s makes sense, but the name may be confusing. symbol types refers specifically to STT_*, while in the test we are checking other properties (visibility/binding/etc).
I can see there being a reason to expand the coverage of the existing test to cover -shared, this would require the rename and potentially splitting the existing test in two. It may also be worth creating one input assembly file that can be used for all these tests mentioned to ensure coverage. Could this wait for a future change however?
Also, with your comment were you suggesting removing some of the existing tests and folding them into the one added here? As they test different functionality I think it may be best to keep them separate.
-shared tests require to check preemptibility. This can usually tested by checking dynamic relocations. You can test them with movl foo@gotpcrel(%rip), %rax
They can be added in this patch. You can add -shared tests in a future change.
- Corrected use of pattern with entry
- Renamed dynamic-list-patterns.s
- Removed changes to export-dynamic-symbol.s
- Change input file names
- Updated quotes
Thanks again MaskRay, to avoid confusion surrounding the term "type" I have renamed the test export-symbols and removed the list of symbols, a number of new uses of weak symbols have also been added to the test. I have also split dynamic-list-cpp into a new test due to the dynamic-list-glob.s name change.
Regarding the testing of shared and preemption I have seen that export-dynamic-symbol.s has testing for this regarding --export-dynamic-symbol, whilst --dynamic-list has testing in dynamic-list-preempt-replace-symbol.s and others. Whilst looking into the behaviour of --dynamic-export I struggled to see the same behaviour. Should it also be affecting shared objects in the same way?
I think testing of shared and preemption could be better expanded in similar tests as I described above. I should better describe the initial reasoning for export-symbols.s as the test is a little vague in what exactly it is covering and the misuse of the term type did not help. The idea was that this would be a test for a number of different symbols to ensure they were being exported, this didn't seem to fit into the existing tests and was not exhaustive but could be good additional coverage. Although a shared object is created in the test, this was only used to check for a symbol that found it's definition elsewhere.
lld/test/ELF/export-symbol-types.s | ||
---|---|---|
10 | You are right that this list was more confusing than helpful, I have removed it. | |
27 | The object file created here is different to the one above, one uses the echo as input, the other this file. |
Looks great!
lld/test/ELF/export-symbols.s | ||
---|---|---|
29 ↗ | (On Diff #269560) | Will be nice to make the table aligned. |
FWIW binutils's --dynamic-list and --export-dynamic-symbol are updated a bit this month. The new semantics should match us. https://sourceware.org/pipermail/binutils/2020-June/
echo '.........' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o for simple tests