-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lld][WebAssembly] Fix non-pie dynamic-linking executable #108146
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
Changes from all commits
82a12e6
06482d7
fb9a6ab
9e234c1
972b540
9c486a4
35ecf24
156e6f2
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,38 @@ | ||
| # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.lib.o %p/Inputs/ret32.s | ||
| # RUN: wasm-ld -m wasm32 --experimental-pic -shared --no-entry %t.lib.o -o %t.lib.so | ||
| # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s | ||
| # RUN: wasm-ld -m wasm32 -Bdynamic %t.o %t.lib.so -o %t.wasm | ||
| # RUN: obj2yaml %t.wasm | FileCheck %s | ||
| # RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS | ||
|
|
||
| .functype ret32 (f32) -> (i32) | ||
| .globl _start | ||
| _start: | ||
| .functype _start () -> () | ||
| i32.const f_p | ||
| drop | ||
| end_function | ||
|
|
||
| .section .data.f_p,"",@ | ||
| f_p: | ||
| .int32 ret32 | ||
| .size f_p, 4 | ||
|
|
||
| # CHECK: Sections: | ||
| # CHECK-NEXT: - Type: CUSTOM | ||
| # CHECK-NEXT: Name: dylink.0 | ||
|
|
||
| # non-pie executable doesn't import __memory_base | ||
| # CHECK: - Type: IMPORT | ||
| # CHECK-NOT: Field: __memory_base | ||
|
|
||
| # CHECK: - Type: EXPORT | ||
| # CHECK: - Name: __wasm_apply_data_relocs | ||
| # CHECK-NEXT: Kind: FUNCTION | ||
|
Collaborator
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 be checking for some more things here? Perhaps we can check that
Contributor
Author
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. do you know any existing tests doing similar things which i can use as an example?
Collaborator
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. Yes, there are a few tests that disassembly stuff. Looks for
Contributor
Author
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. ok. i will take a look.
Contributor
Author
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. done |
||
|
|
||
| # DIS: <__wasm_apply_data_relocs>: | ||
| # DIS-EMPTY: | ||
| # DIS-NEXT: i32.const 1024 | ||
| # DIS-NEXT: global.get 0 | ||
| # DIS-NEXT: i32.store 0 | ||
| # DIS-NEXT: end | ||
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.
Just to confirm, this effectively generates a non-PIC output? And
ctx.isPicnot set?I wonder if we can confirm this this test somehow? Perhaps its enough that we successfully use
i32.const f_p(which would not work if the output was PIC, right?) instead ofi32.const f_p@MBRELThere 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.
ctx.isPicis not set as neither of pie or shared is set.the following is the generated output. it looks reasonable to me.
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.
maybe we can confirm it doesn't have __memory_base/__table_base imports?
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.
done