[PowerPC][Book-E] Fix missing load base in elf_cpu_parse_dynamic().

When I implemented MD DYNAMIC parsing, I was originally passing a
linker_file_t so that the MD code could relocate pointers.

However, it turns out this isn't even filled in until later, so it was
always 0.

Just pass the load base (ef->address) directly, as that's really the only
thing we were interested in in the first place.

This fixes a crash on RB800 where it was trying to write to an unmapped
address when updating the GOT.

Reviewed by:	jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D24105
This commit is contained in:
Brandon Bergren 2020-03-18 02:58:18 +00:00
parent 0a70e97c94
commit 3069380898
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=359062
10 changed files with 11 additions and 11 deletions

View File

@ -331,7 +331,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -327,7 +327,7 @@ elf_cpu_load_file(linker_file_t lf)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -258,7 +258,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -297,7 +297,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -620,7 +620,7 @@ parse_dynamic(elf_file_t ef)
ef->ddbstrtab = ef->strtab;
ef->ddbstrcnt = ef->strsz;
return elf_cpu_parse_dynamic(&ef->lf, ef->dynamic);
return elf_cpu_parse_dynamic(ef->address, ef->dynamic);
}
#define LS_PADDING 0x90909090

View File

@ -503,7 +503,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -403,7 +403,7 @@ ppc32_runtime_resolve()
}
int
elf_cpu_parse_dynamic(linker_file_t lf, Elf_Dyn *dynamic)
elf_cpu_parse_dynamic(caddr_t loadbase, Elf_Dyn *dynamic)
{
Elf_Dyn *dp;
bool has_plt = false;
@ -414,7 +414,7 @@ elf_cpu_parse_dynamic(linker_file_t lf, Elf_Dyn *dynamic)
switch (dp->d_tag) {
case DT_PPC_GOT:
secure_plt = true;
got = (Elf_Addr *)(lf->address + dp->d_un.d_ptr);
got = (Elf_Addr *)(loadbase + dp->d_un.d_ptr);
/* Install runtime resolver canary. */
got[1] = (Elf_Addr)ppc32_runtime_resolve;
got[2] = (Elf_Addr)0;

View File

@ -416,7 +416,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -506,7 +506,7 @@ elf_cpu_unload_file(linker_file_t lf __unused)
}
int
elf_cpu_parse_dynamic(linker_file_t lf __unused, Elf_Dyn *dynamic __unused)
elf_cpu_parse_dynamic(caddr_t loadbase __unused, Elf_Dyn *dynamic __unused)
{
return (0);

View File

@ -305,7 +305,7 @@ int linker_ctf_get(linker_file_t, linker_ctf_t *);
int elf_cpu_load_file(linker_file_t);
int elf_cpu_unload_file(linker_file_t);
int elf_cpu_parse_dynamic(linker_file_t, Elf_Dyn *);
int elf_cpu_parse_dynamic(caddr_t, Elf_Dyn *);
/* values for type */
#define ELF_RELOC_REL 1