Skip to contentSkip to conversation

objtool: reduce memory usage of struct reloc

PATCH Peter Zijlstra 1 participant 1 message Dec 19, 2022 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 8 lines · Thomas Weißschuh

Use a smaller type for the relocation type and move it to a location in the structure where it avoids wasted padding bytes.

Technically ELF could use up to four bytes for the type. But until now only types up to number 43 have been defined.

Reduce the size of struct reloc on x86_64 from 120 to 112 bytes. This structure is allocated a lot and never freed.

Please put in a assertion for this -- I can see this going sideways fast if we ever get this wrong.

static inline void reloc_set_type(struct reloc *reloc, int type)

{
	if (type > (1U << (8*sizeof(reloc->type))))
		WARN_ELF("reloc->type out of range");

	reloc->type = type;
}