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: Tidy elf.h

Reorganize elf.h a bit:

- Move the prototypes higher up so they can be used by the inline
functions.

- Move hash-related code to the bottom.

- Remove the unused ELF_HASH_BITS macro.

No functional changes.

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

+47 -49
+47 -49
tools/objtool/include/objtool/elf.h
··· 83 83 bool jump_table_start; 84 84 }; 85 85 86 - #define ELF_HASH_BITS 20 87 - 88 86 struct elf { 89 87 Elf *elf; 90 88 GElf_Ehdr ehdr; ··· 107 109 struct section *section_data; 108 110 struct symbol *symbol_data; 109 111 }; 110 - 111 - #define OFFSET_STRIDE_BITS 4 112 - #define OFFSET_STRIDE (1UL << OFFSET_STRIDE_BITS) 113 - #define OFFSET_STRIDE_MASK (~(OFFSET_STRIDE - 1)) 114 - 115 - #define for_offset_range(_offset, _start, _end) \ 116 - for (_offset = ((_start) & OFFSET_STRIDE_MASK); \ 117 - _offset >= ((_start) & OFFSET_STRIDE_MASK) && \ 118 - _offset <= ((_end) & OFFSET_STRIDE_MASK); \ 119 - _offset += OFFSET_STRIDE) 120 - 121 - static inline u32 sec_offset_hash(struct section *sec, unsigned long offset) 122 - { 123 - u32 ol, oh, idx = sec->idx; 124 - 125 - offset &= OFFSET_STRIDE_MASK; 126 - 127 - ol = offset; 128 - oh = (offset >> 16) >> 16; 129 - 130 - __jhash_mix(ol, oh, idx); 131 - 132 - return ol; 133 - } 134 - 135 - static inline u32 reloc_hash(struct reloc *reloc) 136 - { 137 - return sec_offset_hash(reloc->sec, reloc->offset); 138 - } 139 - 140 - /* 141 - * Try to see if it's a whole archive (vmlinux.o or module). 142 - * 143 - * Note this will miss the case where a module only has one source file. 144 - */ 145 - static inline bool has_multiple_files(struct elf *elf) 146 - { 147 - return elf->num_files > 1; 148 - } 149 - 150 - static inline int elf_class_addrsize(struct elf *elf) 151 - { 152 - if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32) 153 - return sizeof(u32); 154 - else 155 - return sizeof(u64); 156 - } 157 112 158 113 struct elf *elf_open_read(const char *name, int flags); 159 114 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); ··· 137 186 unsigned long offset, unsigned int len); 138 187 struct symbol *find_func_containing(struct section *sec, unsigned long offset); 139 188 189 + /* 190 + * Try to see if it's a whole archive (vmlinux.o or module). 191 + * 192 + * Note this will miss the case where a module only has one source file. 193 + */ 194 + static inline bool has_multiple_files(struct elf *elf) 195 + { 196 + return elf->num_files > 1; 197 + } 198 + 199 + static inline int elf_class_addrsize(struct elf *elf) 200 + { 201 + if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32) 202 + return sizeof(u32); 203 + else 204 + return sizeof(u64); 205 + } 206 + 140 207 #define for_each_sec(file, sec) \ 141 208 list_for_each_entry(sec, &file->elf->sections, list) 142 209 ··· 166 197 __fake; __fake = NULL) \ 167 198 for_each_sec(file, __sec) \ 168 199 sec_for_each_sym(__sec, sym) 200 + 201 + #define OFFSET_STRIDE_BITS 4 202 + #define OFFSET_STRIDE (1UL << OFFSET_STRIDE_BITS) 203 + #define OFFSET_STRIDE_MASK (~(OFFSET_STRIDE - 1)) 204 + 205 + #define for_offset_range(_offset, _start, _end) \ 206 + for (_offset = ((_start) & OFFSET_STRIDE_MASK); \ 207 + _offset >= ((_start) & OFFSET_STRIDE_MASK) && \ 208 + _offset <= ((_end) & OFFSET_STRIDE_MASK); \ 209 + _offset += OFFSET_STRIDE) 210 + 211 + static inline u32 sec_offset_hash(struct section *sec, unsigned long offset) 212 + { 213 + u32 ol, oh, idx = sec->idx; 214 + 215 + offset &= OFFSET_STRIDE_MASK; 216 + 217 + ol = offset; 218 + oh = (offset >> 16) >> 16; 219 + 220 + __jhash_mix(ol, oh, idx); 221 + 222 + return ol; 223 + } 224 + 225 + static inline u32 reloc_hash(struct reloc *reloc) 226 + { 227 + return sec_offset_hash(reloc->sec, reloc->offset); 228 + } 169 229 170 230 #endif /* _OBJTOOL_ELF_H */