tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]


So, a large part of the reason $ORIGIN still doesn't work is that we
have believed that it isn't possible to identify binaries that use
$ORIGIN from within the kernel, so supporting it fully would add
overhead to all execs.

However, while trawling through elf.h tonight looking for something
else, I noticed this:

   /* Flag values for DT_FLAGS */
   #define DF_ORIGIN       0x00000001      /* uses $ORIGIN */

and it appears with some quick experimentation that with at least the
amd64 toolchain, this flag appears (in a flags entry in the dynamic
section) if and only if "-z origin" is given when linking:

   % gcc foo.o -o foo
   % readelf -d foo | grep FLAG
   Exit 1
   % gcc -Wl,-z,origin foo.o -o foo
   % readelf -d foo | grep FLAG
    0x000000006ffffffb (FLAGS_1)            Flags: ORIGIN

Which seems to me to mean that we can (with only a bit of fuss) find
this flag during exec and do the (somewhat) expensive extra lookups
for supporting $ORIGIN only if it's found.

Am I missing something?

David A. Holland

Home | Main Index | Thread Index | Old Index