1 From: Gerald Schaefer <geraldsc@de.ibm.com>
2 Subject: [S390] module function call optimization
3 References: bnc#532063,LTC#55526
5 commit 504665a91498f43d220b7d0942281067283a35f7
6 Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
7 Date: Thu Mar 26 15:24:36 2009 +0100
9 [S390] module function call optimization
11 Avoid the detour over the PLT if the branch target of a function call
12 in a module is in the range of the bras (16-bit) or brasl (32-bit)
13 instruction. The PLT is still generated but it is unused.
15 Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
17 Acked-by: John Jolly <jjolly@suse.de>
19 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
20 index 59b4e79..eed4a00 100644
21 --- a/arch/s390/kernel/module.c
22 +++ b/arch/s390/kernel/module.c
23 @@ -310,15 +310,20 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
24 info->plt_initialized = 1;
26 if (r_type == R_390_PLTOFF16 ||
27 - r_type == R_390_PLTOFF32
28 - || r_type == R_390_PLTOFF64
30 + r_type == R_390_PLTOFF32 ||
31 + r_type == R_390_PLTOFF64)
32 val = me->arch.plt_offset - me->arch.got_offset +
33 info->plt_offset + rela->r_addend;
35 - val = (Elf_Addr) me->module_core +
36 - me->arch.plt_offset + info->plt_offset +
37 - rela->r_addend - loc;
39 + if (!((r_type == R_390_PLT16DBL &&
40 + val - loc + 0xffffUL < 0x1ffffeUL) ||
41 + (r_type == R_390_PLT32DBL &&
42 + val - loc + 0xffffffffULL < 0x1fffffffeULL)))
43 + val = (Elf_Addr) me->module_core +
44 + me->arch.plt_offset +
46 + val += rela->r_addend - loc;
48 if (r_type == R_390_PLT16DBL)
49 *(unsigned short *) loc = val >> 1;
50 else if (r_type == R_390_PLTOFF16)