summaryrefslogtreecommitdiffstats
path: root/sys/kern/link_elf.c
Commit message (Collapse)AuthorAgeFilesLines
* Add two hooks to signal module load and module unload to MD code.marcel2002-10-191-0/+9
| | | | | | | | | | | | The primary reason for this is to allow MD code to process machine specific attributes, segments or sections in the ELF file and update machine specific state accordingly. An immediate use of this is in the ia64 port where unwind information is updated to allow debugging and tracing in/across modules. Note that this commit does not add the functionality to the ia64 port. See revision 1.9 of ia64/ia64/elf_machdep.c. Validated on: alpha, i386, ia64
* Reduce code duplication by moving the common actions inmarcel2002-10-191-58/+56
| | | | | | | | | link_elf_init(), link_elf_link_preload_finish() and link_elf_load_file() to link_elf_link_common_finish(). Since link_elf_init() did initializations as a side-effect of doing the common actions, keep the initialization in that function. Consequently, link_elf_add_gdb() is now also called to insert the very first link_map() (ie the kernel).
* Non-functional change in preparation of the next commit:marcel2002-10-191-41/+36
| | | | | | Move link_elf_add_gdb(), link_elf_delete_gdb() and link_elf_error() near the top of the file. The *_gdb() functions are moved inside the #ifdef DDB already present there.
* In link_elf_load_file(), when SPARSE_MAPPING is defined and wemarcel2002-10-191-1/+0
| | | | | | | cannot allocate ef->object, we freed ef before bailing out with an error. This is wrong because ef=lf and when we have an error and lf is non-NULL (which holds if we try to alloc ef->object), we free lf and thus ef as part of the bailing-out.
* Fix kernel module loading on ia64. Cross-module function callsmarcel2002-10-151-0/+12
| | | | | | | | | | | | were improperly relocated due to faulty logic in lookup_fdesc() in elf_machdep.c. The symbol index (symidx) was bogusly used for load modules other than the one the relocation applied to. This resulted in bogus bindings and consequently runtime failures. The fix is to use the symbol index only for the module being relocated and to use the symbol name for look-ups in the modules in the dependent list. As such, we need a function to return the symbol name given the linker file and symbol index.
* Be consistent about "static" functions: if the function is markedphk2002-09-281-2/+2
| | | | | | static in its prototype, mark it static at the definition too. Inspired by: FlexeLint warning #512
* Add a workaround for what seems to be confusion between binutils and thejake2002-09-271-0/+10
| | | | | | | | | | | sparc v9 ABI. The Elf_Rela records for local symbols appear to already have the symbol's value added in to the addend field, even though the ABI specifies we need to lookup the symbol and add its value too. This breaks text relocations in klds because the symbol's value is added twice, and the resulting address points off into nowhere land, so for now just use the addend. Tested by: rwatson
* Initiate deorbit burn for the i386-only a.out related support. Moves arepeter2002-09-171-8/+0
| | | | | | | | | | | | | | | under way to move the remnants of the a.out toolchain to ports. As the comment in src/Makefile said, this stuff is deprecated and one should not expect this to remain beyond 4.0-REL. It has already lasted WAY beyond that. Notable exceptions: gcc - I have not touched the a.out generation stuff there. ldd/ldconfig - still have some code to interface with a.out rtld. old as/ld/etc - I have not removed these yet, pending their move to ports. some includes - necessary for ldd/ldconfig for now. Tested on: i386 (extensively), alpha
* Unrot SPARSE_MAPPING code (vm_map_pageable -> vm_map_wire).jake2002-08-291-4/+4
|
* Work around a GCC optimization bug on ia64: In link_elf_symbol_values(),marcel2002-08-241-2/+2
| | | | | | | | | | | | | | | a pointer to a symbol is given and we have to find the containing symbol table. We do this by bounds checking. For some strange reason (ie I haven't found the root cause) the first test succeeded for said symbol, implying that the symbol came from the .dynsym table. In reality however the symbol actually resided in the .symtab table. Needless to say that all that was returned was junk. The upper bounds check was: (symptr - baseptr) < symtab_size This has been rewritten to: symptr < (baseptr + symtab_size) As a side-effect, slightly more optimal (and still correct :-) code can be generated on ia64.
* s/sus/sys/ in the a.out kernel case.peter2002-08-221-1/+1
| | | | Submitted by: julian
* Instead of nlist.h and link.h, use sys/nlist_aout.h and sys/link_elf.hpeter2002-08-221-2/+2
| | | | | This avoids reaching out into userland sources (or worse: /usr/include!) for building the kernel.
* In order to better support flexible and extensible access control,rwatson2002-08-151-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make a series of modifications to the credential arguments relating to file read and write operations to cliarfy which credential is used for what: - Change fo_read() and fo_write() to accept "active_cred" instead of "cred", and change the semantics of consumers of fo_read() and fo_write() to pass the active credential of the thread requesting an operation rather than the cached file cred. The cached file cred is still available in fo_read() and fo_write() consumers via fp->f_cred. These changes largely in sys_generic.c. For each implementation of fo_read() and fo_write(), update cred usage to reflect this change and maintain current semantics: - badfo_readwrite() unchanged - kqueue_read/write() unchanged pipe_read/write() now authorize MAC using active_cred rather than td->td_ucred - soo_read/write() unchanged - vn_read/write() now authorize MAC using active_cred but VOP_READ/WRITE() with fp->f_cred Modify vn_rdwr() to accept two credential arguments instead of a single credential: active_cred and file_cred. Use active_cred for MAC authorization, and select a credential for use in VOP_READ/WRITE() based on whether file_cred is NULL or not. If file_cred is provided, authorize the VOP using that cred, otherwise the active credential, matching current semantics. Modify current vn_rdwr() consumers to pass a file_cred if used in the context of a struct file, and to always pass active_cred. When vn_rdwr() is used without a file_cred, pass NOCRED. These changes should maintain current semantics for read/write, but avoid a redundant passing of fp->f_cred, as well as making it more clear what the origin of each credential is in file descriptor read/write operations. Follow-up commits will make similar changes to other file descriptor operations, and modify the MAC framework to pass both credentials to MAC policy modules so they can implement either semantic for revocation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Don't use the symbol name to lookup the symbol value when we can usemarcel2002-04-251-8/+55
| | | | | | | | | | | | the symbol index defined by the relocation. The elf_lookup() support function is to be used by elf_reloc() when symbol lookups need to be done. The elf_lookup() function operates on the symbol index and will do a symbol name based lookup when such is required, otherwise it uses the symbol index directly. This solves the problem seen on ia64 where the symbol hash table does not contain local symbols and a symbol name based lookup would fail for those symbols. Don't pass the symbol name to elf_reloc(), as it isn't used any more.
* Add function link_elf_get_gp(), specific to ia64 for now, to getmarcel2002-04-211-0/+19
| | | | | | | | | | | | | | | | the DT_PLTGOT value. On ia64 this is the value of GP. We need this to construct function descriptors, but the elf file structure is not exported to MD code. Note that the name of the function is based on the meaning that DT_PLTGOT has on ia64. This may differ on other architectures. As such, link_elf_get_gp() has a high level of MD to it. Renaming the function to describe what DT_* value is returned makes it generic, but also makes the MD code less clear and if we only need this on ia64, then a general name for a specific function doesn't help. In short: I don't know what is "right" at this time, so I'll go with what I have.
* Simple p_ucred -> td_ucred changes to start using the per-thread ucredjhb2002-02-271-7/+6
| | | | reference.
* Fix a number of misspellings of "dependency" and "dependencies" iniedowse2001-11-161-1/+1
| | | | | | | comments and function names. PR: kern/8589 Submitted by: Rajesh Vaidheeswarran <rv@fore.com>
* Add the sysctl "kern.function_list", which currently exports allgreen2001-10-301-0/+23
| | | | | | | | | | | | | | | | | function symbols in the kernel in a list of C strings, with an extra nul-termination at the end. This sysctl requires addition of a new linker operation. Now, linker_file_t's need to respond to "each_function_name" to export their function symbols. Note that the sysctl doesn't currently allow distinguishing multiple symbols with the same name from different modules, but could quite easily without a change to the linker operation. This will be a nicety to have when it can be used. Obtained from: NAI Labs CBOSS project Funded by: DARPA
* Also, machine/profile.h should be necessary for the function prototypegreen2001-10-301-0/+3
| | | | of kmupetext().
* Use kmupetext() for ELF KLDs to allow for increased text segment size.green2001-10-301-0/+6
| | | | | Obtained from: NAI Labs CBOSS project Funded by: DARPA
* The ia64 kernel is now linked dynamically so parse its _DYNAMIC structure.dfr2001-09-151-4/+0
|
* KSE Milestone 2julian2001-09-121-9/+10
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Fix a warning. l_name is managed by us and is malloc/free'ed.peter2001-09-101-1/+1
| | | | It is the userland declaration of l_name that is inconvenient for us.
* Unindent a if (1) { that was left behind in the last commit.peter2001-09-031-46/+44
| | | | (commits were seperated to not obscure the real change)
* Argh. Make the ia64 kernel work in all situations. For some reason,peter2001-09-031-4/+3
| | | | | | | and I still dont know why, this was not failing on the non-kse kernel. It certainly should have since things were using linker_kernel_file unconditionally. This has highlighted a different problem though that means that trying to do a kldload on a non-dynamic kernel will implode.
* Fix some of the GDB linkage setup. The l_name member of the gdb linkagewpaul2001-08-101-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | structure is always free()ed yet only sometimes malloc()ed. In particular, it was simply set to point to l_filename from the a linker_file_t in link_elf_link_preload_finish(). The l_filename had been malloc()ed inside the kern_linker.c module and was being free()ed twice: once by link_elf_unload_file() and again by linker_file_unload(), leading to a panic. How to duplicate the problem: - Pre-load a kernel module from the loader, i.e. if_sis.ko - Boot system - Attempt to unload module with kldunload if_sis - Bewm The problem here is that the case where the module was loaded with kldload after system boot would work correctly, so this bug went unnoticed until I stubbed my toe on it just now. (Also, you can only trip this bug if you compile a kernel with options DDB, but that's the default now.) Fix: remember to malloc() a separate copy of the module name for the l_name member of the gdb linkage structure in three places where the linkage structure can be initialized.
* Previously, the ELF linker would always just store the pointer to agreen2001-08-061-1/+5
| | | | | | | | | | | | filename passed in via the module loader functions in the GDB "sharedlibrary" support structures. This isn't good, since the pointer would become stale in almost every case (not the pre-loaded case, of course). Change this to malloc()ed copy of the string and finally fix the reason that gdb -k's "sharedlibrary" command stopped working. Obtained from: LOMAC/FreeBSD (cf. NAI Labs)
* Use a machine dependent type, Elf_Hashelt, for the elements of the elfjake2001-07-311-5/+5
| | | | | | | | dynamic symbol table buckets and chains. The sparc64 toolchain uses 32 bit .hash entries, unlike other 64 bits architectures (alpha), which use 64 bit entries. Discussed with: dfr, jdp
* With Alfred's permission, remove vm_mtx in favor of a fine-grained approachdillon2001-07-041-8/+2
| | | | | | | | | (this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
* With this commit, I hereby pronounce gensetdefs past its use-by date.peter2001-06-131-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the a.out emulation of 'struct linker_set' with something a little more flexible. <sys/linker_set.h> now provides macros for accessing elements and completely hides the implementation. The linker_set.h macros have been on the back burner in various forms since 1998 and has ideas and code from Mike Smith (SET_FOREACH()), John Polstra (ELF clue) and myself (cleaned up API and the conversion of the rest of the kernel to use it). The macros declare a strongly typed set. They return elements with the type that you declare the set with, rather than a generic void *. For ELF, we use the magic ld symbols (__start_<setname> and __stop_<setname>). Thanks to Richard Henderson <rth@redhat.com> for the trick about how to force ld to provide them for kld's. For a.out, we use the old linker_set struct. NOTE: the item lists are no longer null terminated. This is why the code impact is high in certain areas. The runtime linker has a new method to find the linker set boundaries depending on which backend format is in use. linker sets are still module/kld unfriendly and should never be used for anything that may be modular one day. Reviewed by: eivind
* Include sys/mutex.h to silence a warning.dd2001-06-031-0/+1
|
* Introduce a global lock for the vm subsystem (vm_mtx).alfred2001-05-191-0/+8
| | | | | | | | | | | | | | | | | | | vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-2/+4
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Make this compile in a.out mode. link.h has extra dependencies for a.out.peter2001-02-251-0/+3
|
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-2/+1
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Correct a warning where the r_debug_state() dummy function used to triggerjhb2000-10-061-3/+6
| | | | | | a breakpoint in the kernel didn't use the proper argument list. To avoid having to include the userland link.h header everyhwere that sys/linker.h is used, make r_debug_state() a static function in link_elf.c as well.
* Don't support dynamic linking on ia64 for now - the tools can't cope.dfr2000-09-291-0/+6
|
* Ignore ELF files with 'interpreter' section because KLDs doesn't contain it.bp2000-09-061-0/+5
| | | | Reviewed by: peter
* Move the truncation code out of vn_open and into the open system callmckusick2000-07-041-2/+3
| | | | | | | | | | after the acquisition of any advisory locks. This fix corrects a case in which a process tries to open a file with a non-blocking exclusive lock. Even if it fails to get the lock it would still truncate the file even though its open failed. With this change, the truncation is done only after the lock is successfully acquired. Obtained from: BSD/OS
* Remove unneeded #include <vm/vm_zone.h>phk2000-04-301-1/+0
| | | | Generated by: src/tools/tools/kerninclude
* First round implementation of a fine grain enhanced module to modulepeter2000-04-291-77/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | version dependency system. This isn't quite finished, but it is at a useful stage to do a functional checkpoint. Highlights: - version and dependency metadata is gathered via linker sets, so things are handled the same for static kernels and code built to live in a kld. - The dependencies are at module level (versus at file level). - Dependencies determine kld symbol search order - this means that you cannot link against symbols in another file unless you depend on it. This is so that you cannot accidently unload the target out from underneath the ones referencing it. - It is flexible enough that we can put tags in #include files and macros so that we can get decent hooks for enforcing recompiles on incompatable ABI changes. eg: if we change struct proc, we could force a recompile for all kld's that reference the proc struct. - Tangled dependency references at boot time are sorted. Files are relocated once all their dependencies are already relocated. Caveats: - Loader support is incomplete, but has been worked on seperately. - Actual enforcement of the version number tags is not active yet - just the module dependencies are live. The actual structure of versioning hasn't been agreed on yet. (eg: major.minor, or whatever) - There is some backwards compatability for old modules without metadata but I'm not sure how good it is. This is based on work originally done by Boris Popov (bp@freebsd.org), but I'm not sure he'd recognize much of it now. Don't blame him. :-) Also, ideas have been borrowed from Mike Smith.
* Do not use uprintf() for link time error messages. This has unpleasantpeter2000-04-291-4/+4
| | | | | consequences when it happens in the preload support, before curproc or the tty system exist.
* * Rewrite to use kobj(9) instead of hard-coded function tables.dfr2000-04-241-137/+224
| | | | | | | * Report link errors to stdout with uprintf() so that the user can see what went wrong (PR kern/9214). * Add support code to allow module symbols to be loaded into GDB using the debugger's "sharedlibrary" command.
* Fixed a cast of a pointer to an integer of a possibly different size.bde1999-12-241-3/+3
| | | | | Fixed casts of non-`void *' pointers to uintptr_t. Fixed related style bugs. This file uses perfectly non-KNF formatting for casts.
* Introduce NDFREE (and remove VOP_ABORTOP)eivind1999-12-151-2/+2
|
* Fix an embarresing mistake in the kld symbol lookup for DDB. It shouldpeter1999-11-281-4/+6
| | | | | | | now correctly do a traceback when crashing inside a KLD module. PR: 15014 Submitted by: Vladimir N. Silyaev <vns@delta.odessa.ua>
* 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-0/+4
| | | | Submitted by: phk
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Cast pointers to uintptr_t instead of casting them to u_long, and/or vicebde1999-08-241-3/+3
| | | | versa. Cosmetic.
OpenPOWER on IntegriCloud