Skip to content

Commit 7fe4ed6

Browse files
committed
Modify dlupdate to return error code instead of dso_handle
1 parent 0894687 commit 7fe4ed6

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

compiler-rt/lib/orc/coff_platform.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class COFFPlatformRuntimeState {
110110

111111
const char *dlerror();
112112
void *dlopen(std::string_view Name, int Mode);
113-
void *dlupdate(void *DSOHandle, int Mode);
113+
int dlupdate(void *DSOHandle, int Mode);
114114
int dlclose(void *Header);
115115
void *dlsym(void *Header, std::string_view Symbol);
116116

@@ -142,7 +142,7 @@ class COFFPlatformRuntimeState {
142142
Error dlopenFull(JITDylibState &JDS);
143143
Error dlopenInitialize(JITDylibState &JDS, COFFJITDylibDepInfoMap &DepInfo);
144144

145-
Expected<void *> dlupdateImpl(void *DSOHandle, int Mode);
145+
Error dlupdateImpl(void *DSOHandle, int Mode);
146146
Error dlupdateFull(JITDylibState &JDS);
147147
Error dlupdateInitialize(JITDylibState &JDS);
148148

@@ -270,19 +270,18 @@ void *COFFPlatformRuntimeState::dlopen(std::string_view Path, int Mode) {
270270
}
271271
}
272272

273-
void *COFFPlatformRuntimeState::dlupdate(void *DSOHandle, int Mode) {
273+
int COFFPlatformRuntimeState::dlupdate(void *DSOHandle, int Mode) {
274274
ORC_RT_DEBUG({
275275
std::string S;
276276
printdbg("COFFPlatform::dlupdate(%p) (%s)\n", DSOHandle, S.c_str());
277277
});
278278
std::lock_guard<std::recursive_mutex> Lock(JDStatesMutex);
279-
if (auto H = dlupdateImpl(DSOHandle, Mode))
280-
return *H;
281-
else {
279+
if (auto Err = dlupdateImpl(DSOHandle, Mode)) {
282280
// FIXME: Make dlerror thread safe.
283-
DLFcnError = toString(H.takeError());
284-
return nullptr;
281+
DLFcnError = toString(std::move(Err));
282+
return -1;
285283
}
284+
return 0;
286285
}
287286

288287
int COFFPlatformRuntimeState::dlclose(void *DSOHandle) {
@@ -410,8 +409,7 @@ Error COFFPlatformRuntimeState::dlopenInitialize(
410409
return Error::success();
411410
}
412411

413-
Expected<void *> COFFPlatformRuntimeState::dlupdateImpl(void *DSOHandle,
414-
int Mode) {
412+
Error COFFPlatformRuntimeState::dlupdateImpl(void *DSOHandle, int Mode) {
415413
// Try to find JITDylib state by name.
416414
auto *JDS = getJITDylibStateByHeader(DSOHandle);
417415

@@ -425,10 +423,9 @@ Expected<void *> COFFPlatformRuntimeState::dlupdateImpl(void *DSOHandle,
425423
return make_error<StringError>("dlupdate failed, JITDylib must be open.");
426424

427425
if (auto Err = dlupdateFull(*JDS))
428-
return std::move(Err);
426+
return Err;
429427

430-
// Return the header address.
431-
return JDS->Header;
428+
return Error::success();
432429
}
433430

434431
Error COFFPlatformRuntimeState::dlupdateFull(JITDylibState &JDS) {
@@ -738,7 +735,7 @@ void *__orc_rt_coff_jit_dlopen(const char *path, int mode) {
738735
return COFFPlatformRuntimeState::get().dlopen(path, mode);
739736
}
740737

741-
void *__orc_rt_coff_jit_dlupdate(void *dso_handle, int mode) {
738+
int __orc_rt_coff_jit_dlupdate(void *dso_handle, int mode) {
742739
return COFFPlatformRuntimeState::get().dlupdate(dso_handle, mode);
743740
}
744741

compiler-rt/lib/orc/coff_platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// dlfcn functions.
2020
ORC_RT_INTERFACE const char *__orc_rt_coff_jit_dlerror();
2121
ORC_RT_INTERFACE void *__orc_rt_coff_jit_dlopen(const char *path, int mode);
22-
ORC_RT_INTERFACE void *__orc_rt_coff_jit_dlupdate(void *dso_handle, int mode);
22+
ORC_RT_INTERFACE int __orc_rt_coff_jit_dlupdate(void *dso_handle, int mode);
2323
ORC_RT_INTERFACE int __orc_rt_coff_jit_dlclose(void *header);
2424
ORC_RT_INTERFACE void *__orc_rt_coff_jit_dlsym(void *header,
2525
const char *symbol);

0 commit comments

Comments
 (0)