Flush data cache for executable loadable segments explicitly.
Do not use textsize and do not flush everything between map base and base + textsize, because unmapped areas cannot be flushed. This makes Obj_Entry textsize only use go away, and I will remove it later. Reported by: tuexen Tested by: Mark Millard <marklmi26-fbsd@yahoo.com> Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
880d3c76b5
commit
f846c80a9c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340102
@ -294,6 +294,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
|
|||||||
{
|
{
|
||||||
const Elf_Rela *relalim;
|
const Elf_Rela *relalim;
|
||||||
const Elf_Rela *rela;
|
const Elf_Rela *rela;
|
||||||
|
const Elf_Phdr *phdr;
|
||||||
SymCache *cache;
|
SymCache *cache;
|
||||||
int r = -1;
|
int r = -1;
|
||||||
|
|
||||||
@ -327,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
|
|||||||
if (cache != NULL)
|
if (cache != NULL)
|
||||||
free(cache);
|
free(cache);
|
||||||
|
|
||||||
/* Synchronize icache for text seg in case we made any changes */
|
/*
|
||||||
__syncicache(obj->mapbase, obj->textsize);
|
* Synchronize icache for executable segments in case we made
|
||||||
|
* any changes.
|
||||||
|
*/
|
||||||
|
for (phdr = obj->phdr;
|
||||||
|
(const char *)phdr < (const char *)obj->phdr + obj->phsize;
|
||||||
|
phdr++) {
|
||||||
|
if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) {
|
||||||
|
__syncicache(obj->relocbase + phdr->p_vaddr,
|
||||||
|
phdr->p_memsz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
|
|||||||
{
|
{
|
||||||
const Elf_Rela *relalim;
|
const Elf_Rela *relalim;
|
||||||
const Elf_Rela *rela;
|
const Elf_Rela *rela;
|
||||||
|
const Elf_Phdr *phdr;
|
||||||
SymCache *cache;
|
SymCache *cache;
|
||||||
int bytes = obj->dynsymcount * sizeof(SymCache);
|
int bytes = obj->dynsymcount * sizeof(SymCache);
|
||||||
int r = -1;
|
int r = -1;
|
||||||
@ -327,8 +328,18 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
|
|||||||
if (cache)
|
if (cache)
|
||||||
munmap(cache, bytes);
|
munmap(cache, bytes);
|
||||||
|
|
||||||
/* Synchronize icache for text seg in case we made any changes */
|
/*
|
||||||
__syncicache(obj->mapbase, obj->textsize);
|
* Synchronize icache for executable segments in case we made
|
||||||
|
* any changes.
|
||||||
|
*/
|
||||||
|
for (phdr = obj->phdr;
|
||||||
|
(const char *)phdr < (const char *)obj->phdr + obj->phsize;
|
||||||
|
phdr++) {
|
||||||
|
if (phdr->p_type == PT_LOAD && (phdr->p_flags & PF_X) != 0) {
|
||||||
|
__syncicache(obj->relocbase + phdr->p_vaddr,
|
||||||
|
phdr->p_memsz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user