Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Remove flags argument from elf_create_section()

Simplify the elf_create_section() interface a bit by removing the flags
argument. Most callers don't care about changing the section header
flags. If needed, they can be modified afterwards, just like any other
section header field.

Link: https://lore.kernel.org/r/515235d9cf62637a14bee37bfa9169ef20065471.1685464332.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+18 -15
+10 -7
tools/objtool/check.c
··· 677 677 list_for_each_entry(insn, &file->static_call_list, call_node) 678 678 idx++; 679 679 680 - sec = elf_create_section(file->elf, ".static_call_sites", SHF_WRITE, 680 + sec = elf_create_section(file->elf, ".static_call_sites", 681 681 sizeof(struct static_call_site), idx); 682 682 if (!sec) 683 683 return -1; 684 + 685 + /* Allow modules to set the low bits of static_call_site::key */ 686 + sec->sh.sh_flags |= SHF_WRITE; 684 687 685 688 idx = 0; 686 689 list_for_each_entry(insn, &file->static_call_list, call_node) { ··· 766 763 if (!idx) 767 764 return 0; 768 765 769 - sec = elf_create_section(file->elf, ".retpoline_sites", 0, 766 + sec = elf_create_section(file->elf, ".retpoline_sites", 770 767 sizeof(int), idx); 771 768 if (!sec) { 772 769 WARN("elf_create_section: .retpoline_sites"); ··· 812 809 if (!idx) 813 810 return 0; 814 811 815 - sec = elf_create_section(file->elf, ".return_sites", 0, 812 + sec = elf_create_section(file->elf, ".return_sites", 816 813 sizeof(int), idx); 817 814 if (!sec) { 818 815 WARN("elf_create_section: .return_sites"); ··· 864 861 if (!idx) 865 862 return 0; 866 863 867 - sec = elf_create_section(file->elf, ".ibt_endbr_seal", 0, 864 + sec = elf_create_section(file->elf, ".ibt_endbr_seal", 868 865 sizeof(int), idx); 869 866 if (!sec) { 870 867 WARN("elf_create_section: .ibt_endbr_seal"); ··· 923 920 idx++; 924 921 } 925 922 926 - sec = elf_create_section(file->elf, ".cfi_sites", 0, sizeof(unsigned int), idx); 923 + sec = elf_create_section(file->elf, ".cfi_sites", sizeof(unsigned int), idx); 927 924 if (!sec) 928 925 return -1; 929 926 ··· 971 968 list_for_each_entry(insn, &file->mcount_loc_list, call_node) 972 969 idx++; 973 970 974 - sec = elf_create_section(file->elf, "__mcount_loc", 0, addrsize, idx); 971 + sec = elf_create_section(file->elf, "__mcount_loc", addrsize, idx); 975 972 if (!sec) 976 973 return -1; 977 974 ··· 1016 1013 list_for_each_entry(insn, &file->call_list, call_node) 1017 1014 idx++; 1018 1015 1019 - sec = elf_create_section(file->elf, ".call_sites", 0, sizeof(unsigned int), idx); 1016 + sec = elf_create_section(file->elf, ".call_sites", sizeof(unsigned int), idx); 1020 1017 if (!sec) 1021 1018 return -1; 1022 1019
+5 -5
tools/objtool/elf.c
··· 1059 1059 } 1060 1060 1061 1061 struct section *elf_create_section(struct elf *elf, const char *name, 1062 - unsigned int sh_flags, size_t entsize, int nr) 1062 + size_t entsize, int nr) 1063 1063 { 1064 1064 struct section *sec, *shstrtab; 1065 1065 size_t size = entsize * nr; ··· 1117 1117 sec->sh.sh_entsize = entsize; 1118 1118 sec->sh.sh_type = SHT_PROGBITS; 1119 1119 sec->sh.sh_addralign = 1; 1120 - sec->sh.sh_flags = SHF_ALLOC | sh_flags; 1120 + sec->sh.sh_flags = SHF_ALLOC; 1121 1121 1122 1122 /* Add section name to .shstrtab (or .strtab for Clang) */ 1123 1123 shstrtab = find_section_by_name(elf, ".shstrtab"); ··· 1153 1153 strcpy(relocname, ".rel"); 1154 1154 strcat(relocname, base->name); 1155 1155 1156 - sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rel), 0); 1156 + sec = elf_create_section(elf, relocname, sizeof(GElf_Rel), 0); 1157 1157 free(relocname); 1158 1158 if (!sec) 1159 1159 return NULL; ··· 1185 1185 strcat(relocname, base->name); 1186 1186 1187 1187 if (addrsize == sizeof(u32)) 1188 - sec = elf_create_section(elf, relocname, 0, sizeof(Elf32_Rela), 0); 1188 + sec = elf_create_section(elf, relocname, sizeof(Elf32_Rela), 0); 1189 1189 else 1190 - sec = elf_create_section(elf, relocname, 0, sizeof(GElf_Rela), 0); 1190 + sec = elf_create_section(elf, relocname, sizeof(GElf_Rela), 0); 1191 1191 free(relocname); 1192 1192 if (!sec) 1193 1193 return NULL;
+1 -1
tools/objtool/include/objtool/elf.h
··· 109 109 }; 110 110 111 111 struct elf *elf_open_read(const char *name, int flags); 112 - struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); 112 + struct section *elf_create_section(struct elf *elf, const char *name, size_t entsize, int nr); 113 113 114 114 struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size); 115 115
+2 -2
tools/objtool/orc_gen.c
··· 237 237 WARN("file already has .orc_unwind section, skipping"); 238 238 return -1; 239 239 } 240 - orc_sec = elf_create_section(file->elf, ".orc_unwind", 0, 240 + orc_sec = elf_create_section(file->elf, ".orc_unwind", 241 241 sizeof(struct orc_entry), nr); 242 242 if (!orc_sec) 243 243 return -1; 244 244 245 - sec = elf_create_section(file->elf, ".orc_unwind_ip", 0, sizeof(int), nr); 245 + sec = elf_create_section(file->elf, ".orc_unwind_ip", sizeof(int), nr); 246 246 if (!sec) 247 247 return -1; 248 248