LATX, fix: correct native wrapper ABIs and loader semantics - #393
Conversation
| @@ -3536,29 +3625,28 @@ int init_x86dlfun(void); | |||
| int init_x86dlfun(void) | |||
There was a problem hiding this comment.
(ABI 1.0的)x86dlfun在wrappedlibdl.c里已经有“一份”基础设施,(ABI 2.0)的x86dlfun能否让wrappedlibc.c复用wrappedlibdl.c已有的代码?
There was a problem hiding this comment.
可以,已按这个方向调整。现在将 guest dl* 入口解析和 dlprivate_t 初始化抽到 x86dlfun.c,wrappedlibdl.c 与 wrappedlibc.c 共用。ABI 1.0 保持 libdl.so.2 → libc.so.6 的查找顺序;ABI 2.0 保持 libc.so.6 → libdl.so.2 的查找顺序,并在公共初始化后继续执行 KZT 初始化。见 e07822b。
There was a problem hiding this comment.
嗯,my_dlopen、my_dlmopen、my_dlerror、my_dlsym、my_dlclose、my_dladdr、my_dladdr1、my_dlvsym、my_dlinfo也可以只保留“一份”。
There was a problem hiding this comment.
已按这个方向进一步收敛。现在这 9 个 my_dl* 函数、dlprivate 生命周期函数和内部 helper 都只在 wrappedlibdl.c 保留一份,两种 ABI 均编译该公共实现。ABI 1.0 由 wrappedlibdl.c 条件注册 libdl wrapper,ABI 2.0 仍由 libc 注册;两者只在公共初始化中保留 provider 查找顺序以及 ABI 2.0 的 KZT 后置初始化差异。整理并同步最新主线后的对应提交为 483be7a。
9b1837a to
6dc6e53
Compare
Correct native link-map handling, preserve dlvsym and dlinfo semantics, bound dlopen path expansion, and make dlerror state thread-local. Serialize TB bridge registration, keep generated dlfcn mappings aligned, and scope guest CPU-state forwarding to the paths that require it. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Align X11, XCB, Xt, GL, GLX, EGL, and Vulkan signatures with their native prototypes. Preserve wide scalar and aggregate arguments, bridge custom callbacks and proc-address results, and keep generated tables and shared dispatchers consistent. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Resolve guest dlfcn entry points through one provider helper and compile one shared implementation for both ABI modes. Keep only provider order, ABI-specific registration, and ABI 2.0 KZT initialization conditional. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
6dc6e53 to
483be7a
Compare
Summary
libdl/libcwrapper semantics for link maps, symbol versions, error state, namespaces, and path expansionProblem
LATX native-library forwarding depends on compact signatures that describe argument widths, return classes, and aggregate passing rules. Several wrapper entries used incorrect signatures, including truncated 64-bit values, missing parameters, pointer returns represented as integers, floating-point return classes for integer cookies, and incomplete 16-byte XCB iterator handling. These mismatches can corrupt arguments or return values before the native library is entered.
The dynamic-loader wrappers also mishandled parts of the
dl*contract. Native link maps were read through the wrong pointer level,dlvsymdiscarded its version,dlerrorwas shared and non-consuming, non-basedlmopennamespaces were silently ignored, and path token expansion used fixed-size stack storage. Managed handles could consequently return the wrong link map, resolve the wrong symbol version, leak stale error state across threads, or overwrite memory during path expansion.Dynamic graphics entry-point lookup had related bridging gaps. Missing wrapper metadata could be dereferenced, extension fallback names could lose their canonical bridge key, and some callback/proc-address functions could expose native function pointers directly to translated code.
Changes
Loader semantics
RTLD_DI_LINKMAPthrough the required pointer resultdlsymanddlvsymdlinfoand lazily establish their guest link mapsdlerrordlmopennamespaces instead of weakening namespace isolationdlopenpath buffers with checked dynamic expansionNative ABI forwarding
Callback and proc-address bridging
NULLwhen wrapper metadata or a custom target is unavailableImpact
Native calls now receive the same argument and return layout described by their public C APIs. Loader calls preserve versioning, error, and link-map semantics, while dynamic graphics entry points remain inside the translated bridge boundary.
Validation