* [PATCH-BPF] Fixes in recent BPF commit @ 2023-03-17 16:00 Cupertino Miranda 2023-03-17 16:00 ` [PATCH 1/2] Reloc howto access broken for BPF Cupertino Miranda ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Cupertino Miranda @ 2023-03-17 16:00 UTC (permalink / raw) To: binutils; +Cc: jose.marchesi, elena.zannoni, cupertino.miranda, nickc Hi Jose, Nick, The patches below fix a problem detected by the tests, as well as an update to the tests based on the changes made in BPF relocations. BPF ld is currently broken without the first patch. Looking forward to your review as quickly as you can. Best regards, Cupertino ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Reloc howto access broken for BPF 2023-03-17 16:00 [PATCH-BPF] Fixes in recent BPF commit Cupertino Miranda @ 2023-03-17 16:00 ` Cupertino Miranda 2023-03-17 16:00 ` [PATCH 2/2] Changed ld and gas BPF tests Cupertino Miranda 2023-03-20 11:34 ` [PATCH-BPF] Fixes in recent BPF commit Nick Clifton 2 siblings, 0 replies; 7+ messages in thread From: Cupertino Miranda @ 2023-03-17 16:00 UTC (permalink / raw) To: binutils; +Cc: jose.marchesi, elena.zannoni, cupertino.miranda, nickc Forgot to change the logic to access the reloc howto from bpf_elf_relocate_section. Problem was introduced in previous BPF commit. --- bfd/elf64-bpf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bfd/elf64-bpf.c b/bfd/elf64-bpf.c index ef34d62df01..65418d1d740 100644 --- a/bfd/elf64-bpf.c +++ b/bfd/elf64-bpf.c @@ -190,6 +190,7 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, for (rel = relocs; rel < relend; rel ++) { reloc_howto_type * howto; + unsigned int howto_index; unsigned long r_symndx; Elf_Internal_Sym * sym; asection * sec; @@ -203,7 +204,9 @@ bpf_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, r_type = ELF64_R_TYPE (rel->r_info); r_symndx = ELF64_R_SYM (rel->r_info); - howto = bpf_elf_howto_table + ELF64_R_TYPE (rel->r_info); + + howto_index = bpf_index_for_rtype (ELF64_R_TYPE (rel->r_info)); + howto = &bpf_elf_howto_table[howto_index]; h = NULL; sym = NULL; sec = NULL; -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] Changed ld and gas BPF tests 2023-03-17 16:00 [PATCH-BPF] Fixes in recent BPF commit Cupertino Miranda 2023-03-17 16:00 ` [PATCH 1/2] Reloc howto access broken for BPF Cupertino Miranda @ 2023-03-17 16:00 ` Cupertino Miranda 2023-03-20 14:57 ` Jose E. Marchesi 2023-03-20 11:34 ` [PATCH-BPF] Fixes in recent BPF commit Nick Clifton 2 siblings, 1 reply; 7+ messages in thread From: Cupertino Miranda @ 2023-03-17 16:00 UTC (permalink / raw) To: binutils; +Cc: jose.marchesi, elena.zannoni, cupertino.miranda, nickc Recent BPF patch removed and renamed the list of relocations based on the limitations of BPF instruction set. This patch is a correction to the tests. --- gas/testsuite/gas/bpf/indcall-1.d | 2 +- ld/testsuite/ld-bpf/baz.s | 5 ----- ld/testsuite/ld-bpf/call-1.d | 2 +- ld/testsuite/ld-bpf/jump-1.d | 22 -------------------- ld/testsuite/ld-bpf/reloc-data-be.d | 2 +- ld/testsuite/ld-bpf/reloc-data-le.d | 2 +- ld/testsuite/ld-bpf/reloc-data.s | 4 ---- ld/testsuite/ld-bpf/reloc-insn-external-be.d | 2 -- ld/testsuite/ld-bpf/reloc-insn-external-le.d | 2 -- ld/testsuite/ld-bpf/reloc-insn-external.s | 3 --- ld/testsuite/ld-bpf/reloc-insn32-be.d | 19 ----------------- ld/testsuite/ld-bpf/reloc-insn32-le.d | 19 ----------------- ld/testsuite/ld-bpf/reloc-insn32.s | 20 ------------------ 13 files changed, 4 insertions(+), 100 deletions(-) delete mode 100644 ld/testsuite/ld-bpf/baz.s delete mode 100644 ld/testsuite/ld-bpf/jump-1.d delete mode 100644 ld/testsuite/ld-bpf/reloc-insn32-be.d delete mode 100644 ld/testsuite/ld-bpf/reloc-insn32-le.d delete mode 100644 ld/testsuite/ld-bpf/reloc-insn32.s diff --git a/gas/testsuite/gas/bpf/indcall-1.d b/gas/testsuite/gas/bpf/indcall-1.d index e61e1259fe5..b26e8f8853f 100644 --- a/gas/testsuite/gas/bpf/indcall-1.d +++ b/gas/testsuite/gas/bpf/indcall-1.d @@ -12,7 +12,7 @@ Disassembly of section \.text: 10: b7 02 00 00 02 00 00 00 mov %r2,2 18: 18 06 00 00 38 00 00 00 lddw %r6,0x38 20: 00 00 00 00 00 00 00 00[ ]* - 18: R_BPF_INSN_64 .text + 18: R_BPF_64_64 .text 28: 8d 06 00 00 00 00 00 00 call %r6 30: 95 00 00 00 00 00 00 00 exit diff --git a/ld/testsuite/ld-bpf/baz.s b/ld/testsuite/ld-bpf/baz.s deleted file mode 100644 index 2e159a8829b..00000000000 --- a/ld/testsuite/ld-bpf/baz.s +++ /dev/null @@ -1,5 +0,0 @@ - mov %r1,1 - mov %r2,2 - mov %r3,3 - ja bar - exit diff --git a/ld/testsuite/ld-bpf/call-1.d b/ld/testsuite/ld-bpf/call-1.d index d44c14e9246..aad51d5cedc 100644 --- a/ld/testsuite/ld-bpf/call-1.d +++ b/ld/testsuite/ld-bpf/call-1.d @@ -3,7 +3,7 @@ #source: bar.s #objdump: -dr #ld: -EL -#name: CALL with disp32 reloc +#name: CALL with 64_32 reloc .*: +file format .*bpf.* diff --git a/ld/testsuite/ld-bpf/jump-1.d b/ld/testsuite/ld-bpf/jump-1.d deleted file mode 100644 index 0e3de4edc7b..00000000000 --- a/ld/testsuite/ld-bpf/jump-1.d +++ /dev/null @@ -1,22 +0,0 @@ -#as: --EL -#source: baz.s -#source: bar.s -#objdump: -dr -#ld: -EL -#name: jump with disp16 reloc - -.*: +file format .*bpf.* - -Disassembly of section .text: - -[0-9a-f]+ <.*>: - *[0-9a-f]+: b7 01 00 00 01 00 00 00 mov %r1,1 - *[0-9a-f]+: b7 02 00 00 02 00 00 00 mov %r2,2 - *[0-9a-f]+: b7 03 00 00 03 00 00 00 mov %r3,3 - *[0-9a-f]+: 05 00 01 00 00 00 00 00 ja 1 - *[0-9a-f]+: 95 00 00 00 00 00 00 00 exit - -[0-9a-f]+ <bar>: - *[0-9a-f]+: bf 21 00 00 00 00 00 00 mov %r1,%r2 - *[0-9a-f]+: bf 13 00 00 00 00 00 00 mov %r3,%r1 - *[0-9a-f]+: 95 00 00 00 00 00 00 00 exit diff --git a/ld/testsuite/ld-bpf/reloc-data-be.d b/ld/testsuite/ld-bpf/reloc-data-be.d index 4d793e2b41a..05734b12094 100644 --- a/ld/testsuite/ld-bpf/reloc-data-be.d +++ b/ld/testsuite/ld-bpf/reloc-data-be.d @@ -8,4 +8,4 @@ Contents of section \.data: 0020 666f6f00 62617200 00000000 00000020 .* - 0030 00000028 003034 .* + 0030 00000028 .* diff --git a/ld/testsuite/ld-bpf/reloc-data-le.d b/ld/testsuite/ld-bpf/reloc-data-le.d index 97cb1b36a2a..8cabc7fae5c 100644 --- a/ld/testsuite/ld-bpf/reloc-data-le.d +++ b/ld/testsuite/ld-bpf/reloc-data-le.d @@ -8,4 +8,4 @@ Contents of section \.data: 0020 666f6f00 62617200 20000000 00000000 .* - 0030 28000000 300034 .* + 0030 28000000 .* diff --git a/ld/testsuite/ld-bpf/reloc-data.s b/ld/testsuite/ld-bpf/reloc-data.s index 431ef5aef61..90a5ff06896 100644 --- a/ld/testsuite/ld-bpf/reloc-data.s +++ b/ld/testsuite/ld-bpf/reloc-data.s @@ -10,7 +10,3 @@ d64: .quad foo d32: .word d64 -d16: - .half d32 -d8: - .byte d16 diff --git a/ld/testsuite/ld-bpf/reloc-insn-external-be.d b/ld/testsuite/ld-bpf/reloc-insn-external-be.d index 032d3649d2a..455daa701f7 100644 --- a/ld/testsuite/ld-bpf/reloc-insn-external-be.d +++ b/ld/testsuite/ld-bpf/reloc-insn-external-be.d @@ -12,5 +12,3 @@ Disassembly of section .text: [0-9a-f]+ <.*>: *[0-9a-f]+: 18 10 00 00 00 00 00 28[ ]*lddw %r1,0x28 *[0-9a-f]+: 00 00 00 00 00 00 00 00[ ]* - *[0-9a-f]+: b7 20 00 00 00 00 00 26[ ]*mov %r2,0x26 - *[0-9a-f]+: 61 34 00 24 00 00 00 00[ ]*ldxw %r3,\[%r4\+0x24\] diff --git a/ld/testsuite/ld-bpf/reloc-insn-external-le.d b/ld/testsuite/ld-bpf/reloc-insn-external-le.d index d3513766ee8..51066388e84 100644 --- a/ld/testsuite/ld-bpf/reloc-insn-external-le.d +++ b/ld/testsuite/ld-bpf/reloc-insn-external-le.d @@ -12,5 +12,3 @@ Disassembly of section .text: [0-9a-f]+ <.*>: *[0-9a-f]+: 18 01 00 00 28 00 00 00[ ]*lddw %r1,0x28 *[0-9a-f]+: 00 00 00 00 00 00 00 00[ ]* - *[0-9a-f]+: b7 02 00 00 26 00 00 00[ ]*mov %r2,0x26 - *[0-9a-f]+: 61 43 24 00 00 00 00 00[ ]*ldxw %r3,\[%r4\+0x24\] diff --git a/ld/testsuite/ld-bpf/reloc-insn-external.s b/ld/testsuite/ld-bpf/reloc-insn-external.s index be12813934a..41a35b40afe 100644 --- a/ld/testsuite/ld-bpf/reloc-insn-external.s +++ b/ld/testsuite/ld-bpf/reloc-insn-external.s @@ -1,5 +1,2 @@ lddw %r1, bar + 4 - mov %r2, bar + 2 - - ldxw %r3, [%r4 + bar] diff --git a/ld/testsuite/ld-bpf/reloc-insn32-be.d b/ld/testsuite/ld-bpf/reloc-insn32-be.d deleted file mode 100644 index 27d592d2439..00000000000 --- a/ld/testsuite/ld-bpf/reloc-insn32-be.d +++ /dev/null @@ -1,19 +0,0 @@ -#as: --EB -#source: reloc-insn32.s -#objdump: -d -#ld: -Tdata=0xdabeef -EB -#name: reloc INSN32 BE - -.*: +file format .*bpfbe - -Disassembly of section .text: - -[0-9a-f]+ <main>: - *[0-9a-f]+: b7 10 00 00 00 da be f3[ ]*mov %r1,0xdabef3 - *[0-9a-f]+: 16 10 00 02 00 da be f3[ ]*jeq32 %r1,0xdabef3,2 - *[0-9a-f]+: 38 00 00 00 00 da be ff[ ]*ldabsdw 0xdabeff - *[0-9a-f]+: 95 00 00 00 00 00 00 00[ ]*exit - -[0-9a-f]+ <baz>: - *[0-9a-f]+: 07 10 00 00 00 da be ef[ ]*add %r1,0xdabeef - *[0-9a-f]+: 62 20 00 08 00 da be f7[ ]*stw \[%r2\+8\],0xdabef7 diff --git a/ld/testsuite/ld-bpf/reloc-insn32-le.d b/ld/testsuite/ld-bpf/reloc-insn32-le.d deleted file mode 100644 index bdbb45f28c6..00000000000 --- a/ld/testsuite/ld-bpf/reloc-insn32-le.d +++ /dev/null @@ -1,19 +0,0 @@ -#as: --EL -#source: reloc-insn32.s -#objdump: -d -#ld: -Tdata=0xdabeef -EL -#name: reloc INSN32 LE - -.*: +file format .*bpfle - -Disassembly of section .text: - -[0-9a-f]+ <main>: - *[0-9a-f]+: b7 01 00 00 f3 be da 00[ ]*mov %r1,0xdabef3 - *[0-9a-f]+: 16 01 02 00 f3 be da 00[ ]*jeq32 %r1,0xdabef3,2 - *[0-9a-f]+: 38 00 00 00 ff be da 00[ ]*ldabsdw 0xdabeff - *[0-9a-f]+: 95 00 00 00 00 00 00 00[ ]*exit - -[0-9a-f]+ <baz>: - *[0-9a-f]+: 07 01 00 00 ef be da 00[ ]*add %r1,0xdabeef - *[0-9a-f]+: 62 02 08 00 f7 be da 00[ ]*stw \[%r2\+8\],0xdabef7 diff --git a/ld/testsuite/ld-bpf/reloc-insn32.s b/ld/testsuite/ld-bpf/reloc-insn32.s deleted file mode 100644 index a53a0dc43f8..00000000000 --- a/ld/testsuite/ld-bpf/reloc-insn32.s +++ /dev/null @@ -1,20 +0,0 @@ - .data -foo: - .string "foo" -bar: - .string "bar" -d64: - .dword bar -d32: - .word d64 - - .text -main: - mov %r1, bar - jeq32 %r1, bar, baz - ldabsdw d32 - exit - -baz: - add %r1, foo - stw [%r2 + 8], d64 -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Changed ld and gas BPF tests 2023-03-17 16:00 ` [PATCH 2/2] Changed ld and gas BPF tests Cupertino Miranda @ 2023-03-20 14:57 ` Jose E. Marchesi 2023-03-20 15:31 ` Cupertino Miranda 0 siblings, 1 reply; 7+ messages in thread From: Jose E. Marchesi @ 2023-03-20 14:57 UTC (permalink / raw) To: Cupertino Miranda; +Cc: binutils, elena.zannoni, nickc Hi Cuper. Thanks for the patch. > diff --git a/ld/testsuite/ld-bpf/reloc-data.s b/ld/testsuite/ld-bpf/reloc-data.s > index 431ef5aef61..90a5ff06896 100644 > --- a/ld/testsuite/ld-bpf/reloc-data.s > +++ b/ld/testsuite/ld-bpf/reloc-data.s > @@ -10,7 +10,3 @@ d64: > .quad foo > d32: > .word d64 > -d16: > - .half d32 > -d8: > - .byte d16 > diff --git a/ld/testsuite/ld-bpf/reloc-data-be.d b/ld/testsuite/ld-bpf/reloc-data-be.d > index 4d793e2b41a..05734b12094 100644 > --- a/ld/testsuite/ld-bpf/reloc-data-be.d > +++ b/ld/testsuite/ld-bpf/reloc-data-be.d > @@ -8,4 +8,4 @@ > > Contents of section \.data: > 0020 666f6f00 62617200 00000000 00000020 .* > - 0030 00000028 003034 .* > + 0030 00000028 .* > diff --git a/ld/testsuite/ld-bpf/reloc-data-le.d b/ld/testsuite/ld-bpf/reloc-data-le.d > index 97cb1b36a2a..8cabc7fae5c 100644 > --- a/ld/testsuite/ld-bpf/reloc-data-le.d > +++ b/ld/testsuite/ld-bpf/reloc-data-le.d > @@ -8,4 +8,4 @@ > > Contents of section \.data: > 0020 666f6f00 62617200 20000000 00000000 .* > - 0030 28000000 300034 .* > + 0030 28000000 .* Why removing d16 and d8 from reloc-data.s? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Changed ld and gas BPF tests 2023-03-20 14:57 ` Jose E. Marchesi @ 2023-03-20 15:31 ` Cupertino Miranda 2023-03-20 16:01 ` Jose E. Marchesi 0 siblings, 1 reply; 7+ messages in thread From: Cupertino Miranda @ 2023-03-20 15:31 UTC (permalink / raw) To: Jose E. Marchesi; +Cc: binutils, elena.zannoni, nickc Hi Jose, I removed those relocations. Until proven otherwise the approach was to assume that we will not needed it until we do. I could not come up with an use case that we could practically needed those. Regards, Cupertino Jose E. Marchesi writes: > Hi Cuper. > Thanks for the patch. > >> diff --git a/ld/testsuite/ld-bpf/reloc-data.s b/ld/testsuite/ld-bpf/reloc-data.s >> index 431ef5aef61..90a5ff06896 100644 >> --- a/ld/testsuite/ld-bpf/reloc-data.s >> +++ b/ld/testsuite/ld-bpf/reloc-data.s >> @@ -10,7 +10,3 @@ d64: >> .quad foo >> d32: >> .word d64 >> -d16: >> - .half d32 >> -d8: >> - .byte d16 > >> diff --git a/ld/testsuite/ld-bpf/reloc-data-be.d b/ld/testsuite/ld-bpf/reloc-data-be.d >> index 4d793e2b41a..05734b12094 100644 >> --- a/ld/testsuite/ld-bpf/reloc-data-be.d >> +++ b/ld/testsuite/ld-bpf/reloc-data-be.d >> @@ -8,4 +8,4 @@ >> >> Contents of section \.data: >> 0020 666f6f00 62617200 00000000 00000020 .* >> - 0030 00000028 003034 .* >> + 0030 00000028 .* > >> diff --git a/ld/testsuite/ld-bpf/reloc-data-le.d b/ld/testsuite/ld-bpf/reloc-data-le.d >> index 97cb1b36a2a..8cabc7fae5c 100644 >> --- a/ld/testsuite/ld-bpf/reloc-data-le.d >> +++ b/ld/testsuite/ld-bpf/reloc-data-le.d >> @@ -8,4 +8,4 @@ >> >> Contents of section \.data: >> 0020 666f6f00 62617200 20000000 00000000 .* >> - 0030 28000000 300034 .* >> + 0030 28000000 .* > > Why removing d16 and d8 from reloc-data.s? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Changed ld and gas BPF tests 2023-03-20 15:31 ` Cupertino Miranda @ 2023-03-20 16:01 ` Jose E. Marchesi 0 siblings, 0 replies; 7+ messages in thread From: Jose E. Marchesi @ 2023-03-20 16:01 UTC (permalink / raw) To: Cupertino Miranda; +Cc: binutils, elena.zannoni, nickc > I removed those relocations. Until proven otherwise the approach was to > assume that we will not needed it until we do. I could not come up with > an use case that we could practically needed those. Thanks for the info. The patch is OK. Thanks! > > Regards, > Cupertino > > Jose E. Marchesi writes: > >> Hi Cuper. >> Thanks for the patch. >> >>> diff --git a/ld/testsuite/ld-bpf/reloc-data.s b/ld/testsuite/ld-bpf/reloc-data.s >>> index 431ef5aef61..90a5ff06896 100644 >>> --- a/ld/testsuite/ld-bpf/reloc-data.s >>> +++ b/ld/testsuite/ld-bpf/reloc-data.s >>> @@ -10,7 +10,3 @@ d64: >>> .quad foo >>> d32: >>> .word d64 >>> -d16: >>> - .half d32 >>> -d8: >>> - .byte d16 >> >>> diff --git a/ld/testsuite/ld-bpf/reloc-data-be.d b/ld/testsuite/ld-bpf/reloc-data-be.d >>> index 4d793e2b41a..05734b12094 100644 >>> --- a/ld/testsuite/ld-bpf/reloc-data-be.d >>> +++ b/ld/testsuite/ld-bpf/reloc-data-be.d >>> @@ -8,4 +8,4 @@ >>> >>> Contents of section \.data: >>> 0020 666f6f00 62617200 00000000 00000020 .* >>> - 0030 00000028 003034 .* >>> + 0030 00000028 .* >> >>> diff --git a/ld/testsuite/ld-bpf/reloc-data-le.d b/ld/testsuite/ld-bpf/reloc-data-le.d >>> index 97cb1b36a2a..8cabc7fae5c 100644 >>> --- a/ld/testsuite/ld-bpf/reloc-data-le.d >>> +++ b/ld/testsuite/ld-bpf/reloc-data-le.d >>> @@ -8,4 +8,4 @@ >>> >>> Contents of section \.data: >>> 0020 666f6f00 62617200 20000000 00000000 .* >>> - 0030 28000000 300034 .* >>> + 0030 28000000 .* >> >> Why removing d16 and d8 from reloc-data.s? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH-BPF] Fixes in recent BPF commit 2023-03-17 16:00 [PATCH-BPF] Fixes in recent BPF commit Cupertino Miranda 2023-03-17 16:00 ` [PATCH 1/2] Reloc howto access broken for BPF Cupertino Miranda 2023-03-17 16:00 ` [PATCH 2/2] Changed ld and gas BPF tests Cupertino Miranda @ 2023-03-20 11:34 ` Nick Clifton 2 siblings, 0 replies; 7+ messages in thread From: Nick Clifton @ 2023-03-20 11:34 UTC (permalink / raw) To: Cupertino Miranda, binutils; +Cc: jose.marchesi, elena.zannoni Hi Cupertino, > The patches below fix a problem detected by the tests, as well as an > update to the tests based on the changes made in BPF relocations. > BPF ld is currently broken without the first patch. > > Looking forward to your review as quickly as you can. Looks good to me. Unless Jose has any objections I will say "patch series approved - please apply". Cheers Nick ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-20 16:01 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-17 16:00 [PATCH-BPF] Fixes in recent BPF commit Cupertino Miranda 2023-03-17 16:00 ` [PATCH 1/2] Reloc howto access broken for BPF Cupertino Miranda 2023-03-17 16:00 ` [PATCH 2/2] Changed ld and gas BPF tests Cupertino Miranda 2023-03-20 14:57 ` Jose E. Marchesi 2023-03-20 15:31 ` Cupertino Miranda 2023-03-20 16:01 ` Jose E. Marchesi 2023-03-20 11:34 ` [PATCH-BPF] Fixes in recent BPF commit Nick Clifton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).