-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Object][Wasm] Generate symbol info from name section names #81063
Changes from 8 commits
a137a63
9f11853
c179039
77c1e00
e20dbef
3ba55ba
ebb8eee
e597bda
44893bd
f73f9be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# RUN: yaml2obj %s -o %t.wasm | ||
# RUN: llvm-objdump -t %t.wasm | FileCheck %s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe? Either objdump or nm is sufficient to cover this code, since they both just dump info from the Object, and (hopefully) we have other tests for nm-specific things. I was thinking about updating nm to show symbol sizes for functions (currently we just do it for data symbols) so we could use a name section to test that and get some overlapping coverage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added an nm test to also test that the linking section overrides the name section. I'll move both of the tests to test/Object after #81072 lands |
||
# | ||
# CHECK: SYMBOL TABLE: | ||
# CHECK-NEXT: 00000000 F *UND* my_func_import_name | ||
# CHECK-NEXT: 00000083 g F CODE my_func_export_name | ||
# CHECK-NEXT: 00000086 l F CODE my_func_local_name | ||
# CHECK-NEXT: 00000000 *UND* my_global_import_name | ||
# CHECK-NEXT: 00000001 g GLOBAL my_global_export_name | ||
# CHECK-NEXT: 00000000 l O DATA my_datasegment_name | ||
|
||
--- !WASM | ||
FileHeader: | ||
Version: 0x1 | ||
Sections: | ||
- Type: TYPE | ||
Signatures: | ||
- Index: 0 | ||
ParamTypes: [] | ||
ReturnTypes: [] | ||
- Type: IMPORT | ||
Imports: | ||
- Module: env | ||
Field: foo | ||
Kind: FUNCTION | ||
SigIndex: 0 | ||
- Module: env | ||
Field: bar | ||
Kind: GLOBAL | ||
GlobalType: I32 | ||
GlobalMutable: true | ||
- Module: env | ||
Field: memory | ||
Kind: MEMORY | ||
Memory: | ||
Minimum: 0x1 | ||
- Type: FUNCTION | ||
FunctionTypes: [ 0, 0 ] | ||
- Type: GLOBAL | ||
Globals: | ||
- Index: 1 | ||
Mutable: false | ||
Type: I32 | ||
InitExpr: | ||
Opcode: I32_CONST | ||
Value: 42 | ||
- Type: EXPORT | ||
Exports: | ||
- Name: my_func_export | ||
Kind: FUNCTION | ||
Index: 1 | ||
- Name: my_global_export | ||
Kind: GLOBAL | ||
Index: 1 | ||
- Type: CODE | ||
Functions: | ||
- Index: 1 | ||
Locals: | ||
Body: 00 | ||
- Index: 2 | ||
Locals: | ||
Body: 00 | ||
- Type: DATA | ||
Segments: | ||
- SectionOffset: 0 | ||
InitFlags: 0 | ||
Offset: | ||
Opcode: I32_CONST | ||
Value: 0 | ||
Content: 'abcd1234' | ||
- Type: CUSTOM | ||
Name: name | ||
FunctionNames: | ||
- Index: 0 | ||
Name: my_func_import_name | ||
- Index: 1 | ||
Name: my_func_export_name | ||
- Index: 2 | ||
Name: my_func_local_name | ||
GlobalNames: | ||
- Index: 0 | ||
Name: my_global_import_name | ||
- Index: 1 | ||
Name: my_global_export_name | ||
DataSegmentNames: | ||
- Index: 0 | ||
Name: my_datasegment_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem here is that we can't distinguish between symbols of type
GLOBAL
and symbols of typeDATA
. In dynamic linking we exports data symbols as wasm globals. I guess its not huge deal ifnm
gets this wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the text above about limitations kind of gets at that. You'll just see one
DATA
symbol per segment, and oneGLOBAL
symbol per global but they won't be linked.We could try to be more sophisticated. I guess at least for dylibs we'll know it's a dylib before we parse the name section, right (because there's a custom section before the known sections)? So we could try to get it right in that case.