diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-01-25 12:07:43 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-01-25 12:07:43 +0000 |
commit | 97295d8b7542439c9b300e61fbcfed8329a93a62 (patch) | |
tree | 22cdb57e020a4dbb2837761f2018a35592d2edf8 | |
parent | fab213569d4abe1b3f77a508ee755fc9ffc13a23 (diff) | |
download | FreeBSD-src-97295d8b7542439c9b300e61fbcfed8329a93a62.zip FreeBSD-src-97295d8b7542439c9b300e61fbcfed8329a93a62.tar.gz |
When a statically linked binary is executed (or at least, one without
an interpreter definition in its program header), set the auxiliary
ELF argument AT_BASE to 0 rather than to the address that we would
have mapped the interpreter at if there had been one.
The ELF ABI specifications appear to be ambiguous as to the desired
behavior in this situation, as they define AT_BASE as the base address
of the interpreter, but do not mention what to do if there is none.
On Solaris, AT_BASE will be set to the base address of the static
binary if there is no interpreter, and on Linux, AT_BASE is set to 0.
We go with the Linux semantics as they are of more immediate utility
and allow the early runtime environment to know that the kernel has
not mapped an interpreter, but because AT_PHDR points at the ELF
header for the running binary, it is still possible to retrieve all
required mapping information when the process starts should it be
required. Either approach would be preferable to our current behavior
of passing a pointer to an unmapped region of user memory as AT_BASE.
MFC after: 3 weeks
-rw-r--r-- | sys/kern/imgact_elf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 431ee38..ec96974 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -822,7 +822,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) uprintf("ELF interpreter %s not found\n", interp); return (error); } - } + } else + addr = 0; /* * Construct auxargs table (used by the fixup routine) |