summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
Commit message (Collapse)AuthorAgeFilesLines
* Update a comment in elf_coredump to reflect that if you madviseps2000-02-281-2/+3
| | | | | | | with MADV_NOCORE, its address space is also excluded from a core file. Pointed out by: alc
* Add MAP_NOCORE to mmap(2), and MADV_NOCORE and MADV_CORE to madvise(2).ps2000-02-281-0/+7
| | | | | | | | | | | | This This feature allows you to specify if mmap'd data is included in an application's corefile. Change the type of eflags in struct vm_map_entry from u_char to vm_eflags_t (an unsigned int). Reviewed by: dillon,jdp,alfred Approved by: jkh
* Changed the type used to represent the user stack pointer from `long *'bde1999-12-271-3/+3
| | | | | | | | to `register_t *'. This fixes bugs like misplacement of argc and argv on the user stack on i386's with 64-bit longs. We still use longs to represent "words" like argc and argv, and assume that they are on the stack (and that there is stack). The suword() and fuword() families should also use register_t.
* Introduce NDFREE (and remove VOP_ABORTOP)eivind1999-12-151-1/+2
|
* s/p_cred->pc_ucred/p_ucred/gphk1999-11-211-1/+1
|
* Vnode was left referenced in the case if ELF image is broken.bp1999-11-201-1/+3
| | | | Reviewed by: Peter Wemm <peter@netplex.com.au>
* This is a partial commit of the patch from PR 14914:phk1999-11-161-1/+1
| | | | | | | | | | | | | Alot of the code in sys/kern directly accesses the *Q_HEAD and *Q_ENTRY structures for list operations. This patch makes all list operations in sys/kern use the queue(3) macros, rather than directly accessing the *Q_{HEAD,ENTRY} structures. This batch of changes compile to the same object files. Reviewed by: phk Submitted by: Jake Burkholder <jake@checker.org> PR: 14914
* useracc() the prequel:phk1999-10-291-1/+0
| | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument.
* Trim unused options (or #ifdef for undoc options).peter1999-10-111-1/+0
| | | | Submitted by: phk
* General cleanup of core-dumping code.julian1999-09-011-44/+8
| | | | Submitted by: Sean Fagan,
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Don't follow symlinks on coredumps.dima1999-08-261-3/+3
| | | | Reviewed by: dillon && security-officer
* Fix the previous warning a different way since the emul_path exposure waspeter1999-07-091-7/+5
| | | | | intentional. Avoid the warning by propagating the const filename through to elf_load_file() instead.
* Minor tweak - don't cause a warning.peter1999-07-091-2/+3
| | | | | | | I don't know if it was intentional or not, but it would have printed out: /compat/linux/foo/bar.so: interpreter not found If it was, then I've broken it. De-constifying the 'interp' variable or carrying the constness through to elf_load_file() are alternatives.
* Also try to load the interpreter without prepending "emul_path". This allowsmarcel1999-07-051-7/+11
| | | | | | | | dynamicly linked binaries to run in a chroot'd environment with "emul_path" as the new root. The new behavior of loading interpreters is identical to the principle of overlaying. PR: 10145
* Add the options MAP_PREFAULT and MAP_PREFAULT_PARTIAL to vm_map_find/insert,alc1999-05-171-14/+3
| | | | | | | eliminating the need for the pmap_object_init_pt calls in imgact_* and mmap. Reviewed by: David Greenman <dg@root.com>
* Simplify vm_map_find/insert's interface: remove the MAP_COPY_NEEDED option.alc1999-05-141-3/+3
| | | | | | | It never makes sense to specify MAP_COPY_NEEDED without also specifying MAP_COPY_ON_WRITE, and vice versa. Thus, MAP_COPY_ON_WRITE suffices. Reviewed by: David Greenman <dg@root.com>
* Fix a couple of warnings and some bitrot in comments.peter1999-05-091-3/+1
|
* If you merge this into -stable, please increment __FreeBSD_versionjdp1999-02-201-28/+38
| | | | | | | | | | | | | | | | | in "src/sys/sys/param.h". Fix the ELF image activator so that it can handle dynamic linkers which are executables linked at a fixed address. This improves compliance with the ABI spec, and it opens the door to possibly better dynamic linker performance in the future. I've experimented a bit with a fixed-address dynamic linker, and it works fine. But I don't have any measurements yet to determine whether it's worthwhile. Also, remove a few calculations that were never used for anything. I will increment __FreeBSD_version, since this adds a new capability to the kernel that the dynamic linker might some day rely upon.
* Hide access to vmspace:vm_pmap with inline function vmspace_pmap(). Thisluoqi1999-02-191-2/+2
| | | | | | | is the preparation step for moving pmap storage out of vmspace proper. Reviewed by: Alan Cox <alc@cs.rice.edu> Matthew Dillion <dillon@apollo.backplane.com>
* Change the load address of the ELF dynamic linker from "2L*MAXDSIZ"jdp1999-02-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | to an architecture-specific value defined in <machine/elf.h>. This solves problems on large-memory systems that have a high value for MAXDSIZ. The load address is controlled by a new macro ELF_RTLD_ADDR(vmspace). On the i386 it is hard-wired to 0x08000000, which is the standard SVR4 location for the dynamic linker. On the Alpha, the dynamic linker is loaded MAXDSIZ bytes beyond the start of the program's data segment. This is the same place a userland mmap(0, ...) call would put it, so it ends up just below all the shared libraries. The rationale behind the calculation is that it allows room for the data segment to grow to its maximum possible size. These changes have been tested on the i386 for several months without problems. They have been tested on the Alpha as well, though not for nearly as long. I would like to merge the changes into 3.1 within a week if no problems have surfaced as a result of them.
* Remove MAP_ENTRY_IS_A_MAP 'share' maps. These maps were once used todillon1999-02-071-2/+2
| | | | | | attempt to optimize forks but were essentially given-up on due to problems and replaced with an explicit dup of the vm_map_entry structure. Prior to the removal, they were entirely unused.
* Correct an "&" operator which should have been "&&".jdp1999-02-051-2/+2
| | | | Submitted by: mjacob
* Additional note on last rev: The rationale for this is to allow younewton1999-02-051-1/+1
| | | | | | to run Solaris executables (or executables from any other ELF system) directly off the CD-ROM without having to waste megabytes of disk by copying them to another filesystem just to brand them.
* Created sysctl kern.fallback_elf_brand. Defaults to "none", which willnewton1999-02-051-1/+25
| | | | | | | | give the same behaviour produced before today. If sysadmin sets it to a valid ELF brand, ELF image activator will attempt to run unbranded ELF exectutables as if they were branded with that value. Suggested by: Dima Ruban <dima@best.net>
* Provide elf_brand_inuse() as a method an emulator can use to find outnewton1999-02-041-1/+14
| | | | | whether it is currently in use (which is kinda useful when it's about to unload itself: Lockups are never very much fun, are they?).
* *_execsw static structures cannot be const due to the way they interactdillon1999-01-291-2/+2
| | | | | | with EXEC_SET, DECLARE_MODULE, and module_register. Specifically, module_register. We may eventually be able to make these const, but not now.
* Fix warnings in preparation for adding -Wall -Wcast-qual to thedillon1999-01-271-14/+14
| | | | kernel compile
* Enable Linux threads support by default.julian1999-01-261-5/+1
| | | | | | | | | This takes the conditionals out of the code that has been tested by various people for a while. ps and friends (libkvm) will need a recompile as some proc structure changes are made. Submitted by: "Richard Seaman, Jr." <dick@tar.com>
* Reviewed by: Luoqi Chen, Jordan Hubbardjulian1998-12-191-1/+5
| | | | | | | | | | | | Submitted by: "Richard Seaman, Jr." <lists@tar.com> Obtained from: linux :-) Code to allow Linux Threads to run under FreeBSD. By default not enabled This code is dependent on the conditional COMPAT_LINUX_THREADS (suggested by Garret) This is not yet a 'real' option but will be within some number of hours.
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()archie1998-12-041-3/+3
| | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com>
* Nitpicking and dusting performed on a train. Removes trivial warningsphk1998-10-251-4/+2
| | | | about unused variables, labels and other lint.
* Some cleanups and optimizations:peter1998-10-181-163/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | - Use the system headers method for Elf32/Elf64 symbol compatability - get rid of the UPRINTF debugging. - check the ELF header for compatability much more completely - optimize the section mapper. Use the same direct VM interfaces that imgact_aout.c and kern_exec.c use. - Check the return codes from the vm_* functions better. Some return KERN_* results, not an errno. - prefault the page tables to reduce startup faults on page tables like a.out does. - reset the segment protection to zero for each loop, otherwise each segment could get progressively more privs. (eg: if the first was read/write/execute, and the second was meant to be read/execute, the bug would make the second r/w/x too. In practice this was not a problem because executables are normally laid out with text first.) - Don't impose arbitary limits. Use the limits on headers imposed by the need to fit them into one page. - Remove unused switch() cases now that the verbose debugging is gone. I've been using an earlier version of this for a month or so. This sped up ELF exec speed a bit for me but I found it hard to get consistant benchmarks when I tested it last (a few weeks ago). I'm still bothered by the page read out of order caused by the transition from data to bss. This which requires either part filling the transition page or clearing the remainder.
* *gulp*. Jordan specifically OK'ed this..peter1998-10-161-2/+2
| | | | | | | | This is the bulk of the support for doing kld modules. Two linker_sets were replaced by SYSINIT()'s. VFS's and exec handlers are self registered. kld is now a superset of lkm. I have converted most of them, they will follow as a seperate commit as samples. This all still works as a static a.out kernel using LKM's.
* Don't frob the user stack directly, use suword instead. This fixes thedfr1998-10-151-2/+2
| | | | elf_freebsd_fixup() panic which many people have noticed on the alpha.
* Fixed two potentially serious classes of bugs:dg1998-10-131-4/+4
| | | | | | | | | | | | | | | | 1) The vnode pager wasn't properly tracking the file size due to "size" being page rounded in some cases and not in others. This sometimes resulted in corrupted files. First noticed by Terry Lambert. Fixed by changing the "size" pager_alloc parameter to be a 64bit byte value (as opposed to a 32bit page index) and changing the pagers and their callers to deal with this properly. 2) Fixed a bogus type cast in round_page() and trunc_page() that caused some 64bit offsets and sizes to be scrambled. Removing the cast required adding casts at a few dozen callers. There may be problems with other bogus casts in close-by macros. A quick check seemed to indicate that those were okay, however.
* If an ELF executable has a recognized brand, then believe it.jdp1998-10-111-59/+48
| | | | | | | | | Formerly, the heuristic involving the interpreter path took precedence. Also, print a better error message if the brand is missing or not recognized. If there is no brand at all, give the user a hint that "brandelf" needs to be run.
* Fix a bug which caused the dynamic linker pathname in the PT_INTERPjdp1998-10-031-11/+7
| | | | program header entry to be ignored if a recognized brand was found.
* Restore the core-dumping of all writable segments for ELF executables,jdp1998-09-161-80/+188
| | | | | | | | minus the NULL pointer dereference in rev. 1.33. Also simplify things somewhat by eliminating one traversal of the VM map entries. Finally, eliminate calls to vm_map_{un,}lock_read() which aren't needed here. I originally took them from procfs_map.c, but here we know we are dealing only with the map of the current process.
* Erk. Revert back to 1.31, dumping only data and stack to the corejdp1998-09-151-200/+68
| | | | file, until I can solve a panic that has just cropped up.
* When choosing segments to write to the core file, don't assume thatjdp1998-09-151-2/+3
| | | | writable implies readable.
* Instead of just the data and stack segments, include all writablejdp1998-09-151-68/+199
| | | | | | | | | | | | segments (except memory-mapped devices) in the ELF core file. This is really nice. You get access to the data areas of all shared libraries, and even to files that are mapped read-write. In the future, it might be good to add a new resource limit in the spirit of RLIMIT_CORE. It would specify the maximum sized writable segment to include in core dumps. Segments larger than that would be omitted. This would be useful for programs that map very large files read/write but that still would like to get usable core dumps.
* Viola! The kernel now generates standard ELF core dumps for ELFjdp1998-09-141-16/+280
| | | | | | | executables. Currently only data and stack are included in the core dumps. I am looking into adding the other (mmapped) writable segments as well.
* Add provisions for variant core dump file formats, depending on thejdp1998-09-141-2/+11
| | | | | | | | | | | object format of the executable being dumped. This is the first step toward producing ELF core dumps in the proper format. I will commit the code to generate the ELF core dumps Real Soon Now. In the meantime, ELF executables won't dump core at all. That is probably no less useful than dumping a.out-style core dumps as they have done until now. Submitted by: Alex <garbanzo@hooked.net> (with very minor changes by me)
* Default to FreeBSD if no brand detected. This makes life easier whendfr1998-07-291-5/+12
| | | | bootstrapping from NetBSD/alpha.
* Cast u_longs to uintptr_t before casting them to pointers. Don'tbde1998-07-151-3/+3
| | | | | attempt to even partially support systems with function pointers larger than object pointers.
* Fixed printf format errors.bde1998-07-111-5/+5
|
* Fix a typo which prevented i386 elf from working at all (including Linuxdfr1998-06-081-2/+2
| | | | emulated elf binaries).
* This commit fixes various 64bit portability problems required fordfr1998-06-071-22/+50
| | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time.
* Translate T_PROTFLT to SIGSEGV instead of SIGBUS when running undereivind1998-04-281-1/+2
| | | | | | | | | Linux emulation. This make Allegro Common Lisp 4.3 work under FreeBSD! Submitted by: Fred Gilham <gilham@csl.sri.com> Commented on by: bde, dg, msmith, tg Hoping he got everything right: eivind
OpenPOWER on IntegriCloud