[Bug 249162] Consider passing argc/argv/env to the shared object init function (DT_INIT) for compatibility with glibc
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Sep 7 09:53:52 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=249162
Bug ID: 249162
Summary: Consider passing argc/argv/env to the shared object
init function (DT_INIT) for compatibility with glibc
Product: Base System
Version: Unspecified
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs at FreeBSD.org
Reporter: iwtcex at gmail.com
% cat so_init.c
#include <stdio.h>
void so_init(int argc, char** argv, char** env) {
for (int i = 0; i < argc; i++) {
printf("arg[%d]: %s\n", i, argv[i]);
}
}
% cc -std=c99 -fPIC -shared -Wl,-init=so_init so_init.c -o test.so
% env LD_PRELOAD=$PWD/test.so true 1 2 3
Bus error
% /compat/linux/bin/cc -std=c99 -fPIC -shared -Wl,-init=so_init so_init.c -o
test.so
% env LD_PRELOAD=$PWD/test.so /compat/linux/bin/true 1 2 3
arg[0]: /compat/linux/bin/true
arg[1]: 1
arg[2]: 2
arg[3]: 3
Some notes there:
1. relevant glibc code:
https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-init.c;h=3e72fa3013a6aaeda05fe61a0ae7af5d46640826;hb=HEAD#l58
;
2. rtld already does this for functions referenced in DT_INIT_ARRAY, so it's
enough to replace a call_initfini_pointer call with call_init_pointer.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list