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)
This commit is contained in:
parent
f47a6dce89
commit
bcc92693d4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81201
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user