Skip to content

Commit e6dc459

Browse files
committed
remove custom linker script in favor of implicit section maker symbols
1 parent a4a7384 commit e6dc459

File tree

4 files changed

+6
-32
lines changed

4 files changed

+6
-32
lines changed

tools/swift-inspect/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ if (ANDROID)
3434
Sources/AndroidCLib/heap.c)
3535
target_include_directories(AndroidCLib PUBLIC
3636
Sources/AndroidCLib/include)
37-
target_link_options(AndroidCLib PUBLIC
38-
"-Xlinker" "-T${CMAKE_SOURCE_DIR}/Sources/AndroidCLib/section-text-remote.ld")
3937
set_property(TARGET AndroidCLib PROPERTY POSITION_INDEPENDENT_CODE ON)
4038
endif()
4139

tools/swift-inspect/Package.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ let package = Package(
3737
name: "AndroidCLib",
3838
path: "Sources/AndroidCLib",
3939
publicHeadersPath: "include",
40-
cSettings: [.unsafeFlags(["-fPIC"])],
41-
linkerSettings: [.unsafeFlags(["-Xlinker", "-TSources/AndroidCLib/section-text-remote.ld"])]),
40+
cSettings: [.unsafeFlags(["-fPIC"])]),
4241
.systemLibrary(
4342
name: "SwiftInspectClientInterface"),
4443
.testTarget(

tools/swift-inspect/Sources/AndroidCLib/heap.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
// ensure compiles to simple, position-independent code. It is implemented in C
5959
// for readability/maintainability. It is placed in its own code section to
6060
// simplify calculating its size.
61-
__attribute__((noinline, used, section(".text.remote")))
61+
__attribute__((noinline, used, section("heap_iterator")))
6262
static void heap_iterate_callback(unsigned long base, unsigned long size, void *arg) {
6363
volatile uint64_t *data = (uint64_t*)arg;
6464
while (data[NEXT_FREE_IDX] >= data[MAX_VALID_IDX]) {
@@ -77,17 +77,16 @@ static void heap_iterate_callback(unsigned long base, unsigned long size, void *
7777
data[data[NEXT_FREE_IDX]++] = size;
7878
}
7979

80-
// Linker-populated symbol defined in section-text-remote.ld. Used to calculate
81-
// the size of the heap_iterate_callback function when copying it to a remote
82-
// process for execution.
83-
extern char _remote_code_section_end;
80+
// Both clang and gcc implicitly define __start- and __stop- prefixed symbols
81+
// that mark the start and end of user defined sections.
82+
extern char __stop_heap_iterator[];
8483

8584
void* heap_iterate_callback_start() {
8685
return (void*)heap_iterate_callback;
8786
}
8887

8988
size_t heap_iterate_callback_len() {
90-
return (uintptr_t)&_remote_code_section_end - (uintptr_t)heap_iterate_callback;
89+
return (uintptr_t)__stop_heap_iterator - (uintptr_t)heap_iterate_callback;
9190
}
9291

9392
bool heap_iterate_metadata_init(void* data, size_t len) {

tools/swift-inspect/Sources/AndroidCLib/section-text-remote.ld

-22
This file was deleted.

0 commit comments

Comments
 (0)