-
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 2 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,6 @@ | ||
| .functype f () -> () | ||
| .globl f | ||
| .type f,@function | ||
| f: | ||
| .functype f () -> () | ||
| end_function | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.lib.o %p/Inputs/lib.s | ||
| # RUN: wasm-ld -m wasm32 --experimental-pic -shared --no-entry %t.lib.o -o %t.lib.so | ||
| # RUN: llvm-mc -filetype=obj -mattr=+reference-types -triple=wasm32-unknown-unknown -o %t.o %s | ||
| # RUN: wasm-ld -m wasm32 --features=mutable-globals -Bdynamic --export-table --growable-table --export-memory --export=__stack_pointer --export=__heap_base --export=__heap_end --entry=_start %t.o %t.lib.so -o %t.wasm | ||
|
||
| # RUN: obj2yaml %t.wasm | FileCheck %s | ||
|
|
||
| .tabletype __indirect_function_table, funcref | ||
| .globaltype __memory_base, i32, immutable | ||
|
|
||
| .functype f () -> () | ||
| .functype _start () -> () | ||
|
||
| .globl _start | ||
| .type _start,@function | ||
|
||
| _start: | ||
| .functype _start () -> () | ||
| global.get __memory_base | ||
| i32.const f_p@MBREL | ||
| i32.add | ||
| i32.load 0 | ||
| call_indirect __indirect_function_table, () -> () | ||
|
||
| end_function | ||
|
|
||
| .section .data.f_p,"",@ | ||
| .globl f_p | ||
|
||
| f_p: | ||
| .int32 f | ||
| .size f_p, 4 | ||
|
|
||
| # CHECK: Sections: | ||
| # CHECK-NEXT: - Type: CUSTOM | ||
| # CHECK-NEXT: Name: dylink.0 | ||
|
|
||
| # 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 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,7 +146,8 @@ void scanRelocations(InputChunk *chunk) { | |
|
|
||
| if (ctx.isPic || | ||
| (sym->isUndefined() && | ||
| config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic)) { | ||
| config->unresolvedSymbols == UnresolvedPolicy::ImportDynamic) || | ||
| sym->isShared()) { | ||
|
||
| switch (reloc.Type) { | ||
| case R_WASM_TABLE_INDEX_SLEB: | ||
| case R_WASM_TABLE_INDEX_SLEB64: | ||
|
|
||
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.
Rather than creating a new file here you can just pick an existing file such as
ret32.sand compile thatThere 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.
ok. i will try.
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