objtool: Fix x86 orc generation on big endian cross-compiles
Correct objtool orc generation endianness problems to enable fully functional x86 cross-compiles on big endian hardware. Introduce bswap_if_needed() macro, which does a byte swap if target endianness doesn't match the host, i.e. cross-compilation for little endian on big endian and vice versa. The macro is used for conversion of multi-byte values which are read from / about to be written to a target native endianness ELF file. Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
committed by
Josh Poimboeuf
parent
a1a664ece5
commit
8bfe273238
@@ -15,6 +15,7 @@
|
||||
#include "special.h"
|
||||
#include "warn.h"
|
||||
#include "arch_special.h"
|
||||
#include "endianness.h"
|
||||
|
||||
struct special_entry {
|
||||
const char *sec;
|
||||
@@ -77,8 +78,9 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry,
|
||||
if (entry->feature) {
|
||||
unsigned short feature;
|
||||
|
||||
feature = *(unsigned short *)(sec->data->d_buf + offset +
|
||||
entry->feature);
|
||||
feature = bswap_if_needed(*(unsigned short *)(sec->data->d_buf +
|
||||
offset +
|
||||
entry->feature));
|
||||
arch_handle_alternative(feature, alt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user