Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
modpost: fix inverted logic in is_extable_fault_address().
Browse files Browse the repository at this point in the history
As Guenter pointed out, we want to assert that extable_entry_size has been
discovered and not the other way around.  Moreover, this sanity check is
only valid when we're not dealing with the first relocation in __ex_table,
since we have not discovered the extable entry size at that point.

This was leading to a divide-by-zero on some architectures and make the
build fail.

Signed-off-by: Quentin Casasnovas <[email protected]>
Reported-by: Guenter Roeck <[email protected]>
CC: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
Quentin Casasnovas authored and rustyrussell committed Apr 22, 2015
1 parent 6c730bf commit d3df4de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/mod/modpost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,12 @@ static void find_extable_entry_size(const char* const sec, const Elf_Rela* r,
}
static inline bool is_extable_fault_address(Elf_Rela *r)
{
if (!extable_entry_size == 0)
/*
* extable_entry_size is only discovered after we've handled the
* _second_ relocation in __ex_table, so only abort when we're not
* handling the first reloc and extable_entry_size is zero.
*/
if (r->r_offset && extable_entry_size == 0)
fatal("extable_entry size hasn't been discovered!\n");

return ((r->r_offset == 0) ||
Expand Down

0 comments on commit d3df4de

Please sign in to comment.