lkml.org 
[lkml]   [2023]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v4 13/21] modpost: replace r->r_offset, r->r_addend with faddr, taddr
Date
r_offset/r_addend holds the offset address from/to which a symbol is
referenced. It is unclear unless you are familiar with ELF.

Rename them to faddr, taddr, respectively. The prefix 'f' means 'from',
't' means 'to'.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

scripts/mod/modpost.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 9e81cd6803a7..43ce35377f6a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1160,18 +1160,18 @@ static bool is_executable_section(struct elf_info *elf, unsigned int secndx)

static void default_mismatch_handler(const char *modname, struct elf_info *elf,
const struct sectioncheck* const mismatch,
- Elf_Rela *r, Elf_Sym *tsym,
- unsigned int fsecndx, const char *fromsec,
- const char *tosec)
+ Elf_Sym *tsym,
+ unsigned int fsecndx, const char *fromsec, Elf_Addr faddr,
+ const char *tosec, Elf_Addr taddr)
{
Elf_Sym *from;
const char *tosym;
const char *fromsym;

- from = find_nearest_symbol(elf, r->r_offset, fsecndx);
+ from = find_nearest_symbol(elf, faddr, fsecndx);
fromsym = sym_name(elf, from);

- tsym = find_better_symbol(elf, r->r_addend, tsym);
+ tsym = find_better_symbol(elf, taddr, tsym);
tosym = sym_name(elf, tsym);

/* check whitelist - we may ignore it */
@@ -1198,7 +1198,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
break;
case EXTABLE_TO_NON_TEXT:
warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
- modname, fromsec, (long)r->r_offset, tosec, tosym);
+ modname, fromsec, (long)faddr, tosec, tosym);

if (match(tosec, mismatch->bad_tosec))
fatal("The relocation at %s+0x%lx references\n"
@@ -1206,7 +1206,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
"Something is seriously wrong and should be fixed.\n"
"You might get more information about where this is\n"
"coming from by using scripts/check_extable.sh %s\n",
- fromsec, (long)r->r_offset, tosec, modname);
+ fromsec, (long)faddr, tosec, modname);
else if (is_executable_section(elf, get_secindex(elf, tsym)))
warn("The relocation at %s+0x%lx references\n"
"section \"%s\" which is not in the list of\n"
@@ -1215,17 +1215,18 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
"list of authorized sections to jump to on fault.\n"
"This can be achieved by adding \"%s\" to\n"
"OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n",
- fromsec, (long)r->r_offset, tosec, tosec, tosec);
+ fromsec, (long)faddr, tosec, tosec, tosec);
else
error("%s+0x%lx references non-executable section '%s'\n",
- fromsec, (long)r->r_offset, tosec);
+ fromsec, (long)faddr, tosec);
break;
}
}

static void check_section_mismatch(const char *modname, struct elf_info *elf,
- Elf_Rela *r, Elf_Sym *sym,
- unsigned int fsecndx, const char *fromsec)
+ Elf_Sym *sym,
+ unsigned int fsecndx, const char *fromsec,
+ Elf_Addr faddr, Elf_Addr taddr)
{
const char *tosec = sec_name(elf, get_secindex(elf, sym));
const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec);
@@ -1233,8 +1234,9 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
if (!mismatch)
return;

- default_mismatch_handler(modname, elf, mismatch, r, sym, fsecndx, fromsec,
- tosec);
+ default_mismatch_handler(modname, elf, mismatch, sym,
+ fsecndx, fromsec, faddr,
+ tosec, taddr);
}

static unsigned int *reloc_location(struct elf_info *elf,
@@ -1392,7 +1394,8 @@ static void section_rela(const char *modname, struct elf_info *elf,
/* Skip special sections */
if (is_shndx_special(sym->st_shndx))
continue;
- check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
+ check_section_mismatch(modname, elf, sym,
+ fsecndx, fromsec, r.r_offset, r.r_addend);
}
}

@@ -1450,7 +1453,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
/* Skip special sections */
if (is_shndx_special(sym->st_shndx))
continue;
- check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
+ check_section_mismatch(modname, elf, sym,
+ fsecndx, fromsec, r.r_offset, r.r_addend);
}
}

--
2.39.2
\
 
 \ /
  Last update: 2023-05-13 22:47    [W:0.121 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site