mirror of https://github.com/dynup/kpatch
create-diff-object.c: add s390 support for __LINE__ detection
Technically we don't support s390 yet, but it's coming soon and there's no harm in merging this one early. In fact this came in handy for testing my endian fixes with #1203. Note it doesn't actually do anything since 'kelf->arch' can't actually get set to 'S390' yet. But it should work nicely with #1203 as it evolves. This is based on the patch from C. Erastus Toe in #1243, though there may still be a few outstanding issues to look at in that PR, based on some of the code review comments. Originally-by: C. Erastus Toe <ctoe@redhat.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
parent
a6920b9381
commit
e6b1664d0e
|
@ -579,18 +579,30 @@ out:
|
|||
|
||||
static unsigned int insn_length(struct kpatch_elf *kelf, void *addr)
|
||||
{
|
||||
struct insn insn;
|
||||
struct insn decoded_insn;
|
||||
char *insn = addr;
|
||||
|
||||
switch(kelf->arch) {
|
||||
|
||||
case X86_64:
|
||||
insn_init(&insn, addr, 1);
|
||||
insn_get_length(&insn);
|
||||
return insn.length;
|
||||
insn_init(&decoded_insn, addr, 1);
|
||||
insn_get_length(&decoded_insn);
|
||||
return decoded_insn.length;
|
||||
|
||||
case PPC64:
|
||||
return 4;
|
||||
|
||||
case S390:
|
||||
switch(insn[0] >> 6) {
|
||||
case 0:
|
||||
return 2;
|
||||
case 1:
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 6;
|
||||
}
|
||||
|
||||
default:
|
||||
ERROR("unsupported arch");
|
||||
}
|
||||
|
@ -638,6 +650,12 @@ static bool insn_is_load_immediate(struct kpatch_elf *kelf, void *addr)
|
|||
|
||||
break;
|
||||
|
||||
case S390:
|
||||
/* lghi %r4, imm */
|
||||
if (insn[0] == 0xa7 && insn[1] == 0x49)
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR("unsupported arch");
|
||||
}
|
||||
|
|
|
@ -112,6 +112,7 @@ struct string {
|
|||
enum architecture {
|
||||
PPC64 = 0x1 << 0,
|
||||
X86_64 = 0x1 << 1,
|
||||
S390 = 0x1 << 2,
|
||||
};
|
||||
|
||||
struct kpatch_elf {
|
||||
|
|
Loading…
Reference in New Issue