Skip to contentSkip to conversation

objtool: Remove redundant section name comparison

PATCH In review Muchun Song 2 participants 2 messages Apr 12, 2020 – Apr 14, 2020 objtool

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 objtool: Remove redundant section name comparison

If the prefix of section name is not '.rodata', the following function call can never return 0.

    strcmp(sec->name, C_JUMP_TABLE_SECTION)

So the name comparison is pointless, just remove it.

---
 tools/objtool/check.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/objtool/check.c +2 -2
index e637a4a38d2ad..401963179f1b9 100644
@@ -1361,8 +1361,8 @@ static void mark_rodata(struct objtool_file *file)
 	 * .rodata.str1.* sections are ignored; they don't contain jump tables.
 	 */
 	for_each_sec(file, sec) {
-		if ((!strncmp(sec->name, ".rodata", 7) && !strstr(sec->name, ".str1.")) ||
-		    !strcmp(sec->name, C_JUMP_TABLE_SECTION)) {
+		if (!strncmp(sec->name, ".rodata", 7) &&
+		    !strstr(sec->name, ".str1.")) {
 			sec->rodata = true;
 			found = true;
 		}
Signature · 1 line
2.11.0
#1 lore raw
Quoted 8 lines · Muchun Song

If the prefix of section name is not '.rodata', the following function call can never return 0.

    strcmp(sec->name, C_JUMP_TABLE_SECTION)

So the name comparison is pointless, just remove it.

Thanks, added to the queue.

Signature · 1 line
Josh