diff options
author | Brian Feldman <green@FreeBSD.org> | 2001-08-06 14:21:57 +0000 |
---|---|---|
committer | Brian Feldman <green@FreeBSD.org> | 2001-08-06 14:21:57 +0000 |
commit | bcc92693d473d719a23c61dc5f731e5a4ef92b3c (patch) | |
tree | 52036adbafd792c9fc4eb313891d22d82dc76a8d /sys/kern/link_elf.c | |
parent | f47a6dce89dce838a2a368312b6eb46fdd02a86e (diff) | |
download | src-bcc92693d473d719a23c61dc5f731e5a4ef92b3c.tar.gz src-bcc92693d473d719a23c61dc5f731e5a4ef92b3c.zip |
Previously, the ELF linker would always just store the pointer to a
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)
Notes
Notes:
svn path=/head/; revision=81201
Diffstat (limited to 'sys/kern/link_elf.c')
-rw-r--r-- | sys/kern/link_elf.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index faaf160ee77a..785d23a7ee97 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -530,6 +530,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu int symstrindex; int symcnt; int strcnt; + char *newfilename; GIANT_REQUIRED; @@ -788,7 +789,9 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu #ifdef DDB GDB_STATE(RT_ADD); ef->gdb.l_addr = lf->address; - ef->gdb.l_name = filename; + newfilename = malloc(strlen(filename) + 1, M_LINKER, M_WAITOK); + strcpy(newfilename, filename); + ef->gdb.l_name = (const char *)newfilename; ef->gdb.l_ld = ef->dynamic; link_elf_add_gdb(&ef->gdb); GDB_STATE(RT_CONSISTENT); @@ -819,6 +822,7 @@ link_elf_unload_file(linker_file_t file) #ifdef DDB if (ef->gdb.l_ld) { GDB_STATE(RT_DELETE); + free((void *)ef->gdb.l_name, M_LINKER); link_elf_delete_gdb(&ef->gdb); GDB_STATE(RT_CONSISTENT); } |