mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	objtool: Get rid of reloc->jump_table_start
Rework the jump table logic slightly so 'jump_table_start' is no longer needed. With allyesconfig + CONFIG_DEBUG_INFO: - Before: peak heap memory consumption: 40.37G - After: peak heap memory consumption: 38.64G Link: https://lore.kernel.org/r/e1602ed8a6171ada3cfac0bd8449892ec82bd188.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
This commit is contained in:
		
							parent
							
								
									0696b6e314
								
							
						
					
					
						commit
						be2f0b1e12
					
				
					 2 changed files with 23 additions and 13 deletions
				
			
		| 
						 | 
					@ -1989,13 +1989,14 @@ static int add_special_section_alts(struct objtool_file *file)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int add_jump_table(struct objtool_file *file, struct instruction *insn,
 | 
					static int add_jump_table(struct objtool_file *file, struct instruction *insn,
 | 
				
			||||||
			    struct reloc *table)
 | 
								  struct reloc *next_table)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct reloc *reloc = table;
 | 
					 | 
				
			||||||
	struct instruction *dest_insn;
 | 
					 | 
				
			||||||
	struct alternative *alt;
 | 
					 | 
				
			||||||
	struct symbol *pfunc = insn_func(insn)->pfunc;
 | 
						struct symbol *pfunc = insn_func(insn)->pfunc;
 | 
				
			||||||
 | 
						struct reloc *table = insn_jump_table(insn);
 | 
				
			||||||
 | 
						struct instruction *dest_insn;
 | 
				
			||||||
	unsigned int prev_offset = 0;
 | 
						unsigned int prev_offset = 0;
 | 
				
			||||||
 | 
						struct reloc *reloc = table;
 | 
				
			||||||
 | 
						struct alternative *alt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Each @reloc is a switch table relocation which points to the target
 | 
						 * Each @reloc is a switch table relocation which points to the target
 | 
				
			||||||
| 
						 | 
					@ -2004,7 +2005,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
 | 
				
			||||||
	for_each_reloc_from(table->sec, reloc) {
 | 
						for_each_reloc_from(table->sec, reloc) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Check for the end of the table: */
 | 
							/* Check for the end of the table: */
 | 
				
			||||||
		if (reloc != table && reloc->jump_table_start)
 | 
							if (reloc != table && reloc == next_table)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Make sure the table entries are consecutive: */
 | 
							/* Make sure the table entries are consecutive: */
 | 
				
			||||||
| 
						 | 
					@ -2119,29 +2120,39 @@ static void mark_func_jump_tables(struct objtool_file *file,
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		reloc = find_jump_table(file, func, insn);
 | 
							reloc = find_jump_table(file, func, insn);
 | 
				
			||||||
		if (reloc) {
 | 
							if (reloc)
 | 
				
			||||||
			reloc->jump_table_start = true;
 | 
					 | 
				
			||||||
			insn->_jump_table = reloc;
 | 
								insn->_jump_table = reloc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int add_func_jump_tables(struct objtool_file *file,
 | 
					static int add_func_jump_tables(struct objtool_file *file,
 | 
				
			||||||
				  struct symbol *func)
 | 
									  struct symbol *func)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct instruction *insn;
 | 
						struct instruction *insn, *insn_t1 = NULL, *insn_t2;
 | 
				
			||||||
	int ret;
 | 
						int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	func_for_each_insn(file, func, insn) {
 | 
						func_for_each_insn(file, func, insn) {
 | 
				
			||||||
		if (!insn_jump_table(insn))
 | 
							if (!insn_jump_table(insn))
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ret = add_jump_table(file, insn, insn_jump_table(insn));
 | 
							if (!insn_t1) {
 | 
				
			||||||
		if (ret)
 | 
								insn_t1 = insn;
 | 
				
			||||||
			return ret;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
							insn_t2 = insn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ret = add_jump_table(file, insn_t1, insn_jump_table(insn_t2));
 | 
				
			||||||
 | 
							if (ret)
 | 
				
			||||||
 | 
								return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							insn_t1 = insn_t2;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (insn_t1)
 | 
				
			||||||
 | 
							ret = add_jump_table(file, insn_t1, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,7 +75,6 @@ struct reloc {
 | 
				
			||||||
	struct section *sec;
 | 
						struct section *sec;
 | 
				
			||||||
	struct symbol *sym;
 | 
						struct symbol *sym;
 | 
				
			||||||
	struct list_head sym_reloc_entry;
 | 
						struct list_head sym_reloc_entry;
 | 
				
			||||||
	bool jump_table_start;
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct elf {
 | 
					struct elf {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue