[Bug gas/27411] New: [ARM] Wrong error message when assembler cannot honor width suffix ("lo register required")

2021-02-13 Thread kordalski.wojciech at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27411

Bug ID: 27411
   Summary: [ARM] Wrong error message when assembler cannot honor
width suffix ("lo register required")
   Product: binutils
   Version: 2.35.1
Status: UNCONFIRMED
  Severity: minor
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: kordalski.wojciech at gmail dot com
  Target Milestone: ---

Created attachment 13223
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13223&action=edit
Code that generates wrong assembler error message

For some instructions GAS returns wrong error message.

Code:

  ```
  .syntax unified
  .thumb

  .align 2
  .type f1, %function
  .thumb_func
  f1:
  add.n r4, #8
  ```

gives error message: 
  test.s:8: Error: lo register required -- `add.n r4,#8'

Same for `sub.n` instruction.

The right error message would be the one returned for `lsl.n` instruction:
  test.s:8: Error: cannot honor width suffix -- `lsl.n r4,#8'

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/27412] New: Suspicious "setting incorrect section attributes for .note.Linux" warnings on linux kernel

2021-02-13 Thread slyfox at inbox dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=27412

Bug ID: 27412
   Summary: Suspicious "setting incorrect section attributes for
.note.Linux" warnings on linux kernel
   Product: binutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: slyfox at inbox dot ru
CC: amodra at gmail dot com, hjl.tools at gmail dot com
  Target Milestone: ---

When building current linux-5.10 (or master) with gcc-11/binutins-2.36 gas
complains about incorrect (used) section flags. Minimal reproducer:

$ cat bug.c
static const int _note_55 __attribute__((__used__))
__attribute__((section(".note.Linux"))) = 42;

$ gcc-11.0.0 -c bug.c -o bug-11.o -fno-ident
  /tmp/ccJ9p7TD.s: Assembler messages:
  /tmp/ccJ9p7TD.s:3: Warning: setting incorrect section attributes for
.note.Linux

$ gcc-10.2.0 -c bug.c -o bug-11.o -fno-ident
  

gcc-11 generates the following code:

$ gcc-11.0.0 -S bug.c -o bug-11.s -fno-ident  && cat bug-11.s
.file   "bug.c"
.text
.section.note.Linux,"aR"
.align 4
.type   _note_55, @object
.size   _note_55, 4
_note_55:
.long   42
.section.note.GNU-stack,"",@progbits

gcc-10 for completeness:

$ gcc-10.2.0 -S bug.c -o bug-11.s -fno-ident  && cat bug-11.s
.file   "bug.c"
.text
.section.note.Linux,"a"
.align 4
.type   _note_55, @object
.size   _note_55, 4
_note_55:
.long   42
.section.note.GNU-stack,"",@progbits

Original code comes from:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/elfnote.h#n71

Is it a real problem or a false positive warning? Currently
gcc-11/binutils-2.36 generates kernels that can't load some modules and
complain about a bunch of orphan sections. I wonder if this warhing is related
and somehow affects future linking.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/27412] Suspicious "setting incorrect section attributes for .note.Linux" warnings on linux kernel

2021-02-13 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27412

H.J. Lu  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2021-02-13
 Ever confirmed|0   |1

--- Comment #1 from H.J. Lu  ---
(In reply to Sergei Trofimovich from comment #0)
> When building current linux-5.10 (or master) with gcc-11/binutins-2.36 gas
> complains about incorrect (used) section flags. Minimal reproducer:
> 
> $ cat bug.c
> static const int _note_55 __attribute__((__used__))
> __attribute__((section(".note.Linux"))) = 42;
> 
> $ gcc-11.0.0 -c bug.c -o bug-11.o -fno-ident
>   /tmp/ccJ9p7TD.s: Assembler messages:
>   /tmp/ccJ9p7TD.s:3: Warning: setting incorrect section attributes for
> .note.Linux

This is an assembler bug.

> 
> Is it a real problem or a false positive warning? Currently
> gcc-11/binutils-2.36 generates kernels that can't load some modules and
> complain about a bunch of orphan sections. I wonder if this warhing is
> related and somehow affects future linking.

Please try:

https://github.com/hjl-tools/linux/commit/d97c4aeb041b756861bb16ee895e2616f4b4061a

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/27412] Suspicious "setting incorrect section attributes for .note.Linux" warnings on linux kernel

2021-02-13 Thread slyfox at inbox dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=27412

--- Comment #2 from Sergei Trofimovich  ---
(In reply to H.J. Lu from comment #1)
> (In reply to Sergei Trofimovich from comment #0)
> > When building current linux-5.10 (or master) with gcc-11/binutins-2.36 gas
> > complains about incorrect (used) section flags. Minimal reproducer:
> > 
> > $ cat bug.c
> > static const int _note_55 __attribute__((__used__))
> > __attribute__((section(".note.Linux"))) = 42;
> > 
> > $ gcc-11.0.0 -c bug.c -o bug-11.o -fno-ident
> >   /tmp/ccJ9p7TD.s: Assembler messages:
> >   /tmp/ccJ9p7TD.s:3: Warning: setting incorrect section attributes for
> > .note.Linux
> 
> This is an assembler bug.

Aha. I'll ignore the warning for now then.

> > Is it a real problem or a false positive warning? Currently
> > gcc-11/binutils-2.36 generates kernels that can't load some modules and
> > complain about a bunch of orphan sections. I wonder if this warhing is
> > related and somehow affects future linking.

> Please try:
> 
> https://github.com/hjl-tools/linux/commit/
> d97c4aeb041b756861bb16ee895e2616f4b4061a

Did not help. More details of what I see:

When I try to load mei-me.ko kernel crashes in jump_labels init as if there are
no certain sections (maybe data sections?):

$ modprobe mei-me
$ dmesg
BUG: unable to handle page fault for address: c006eb90
#PF: supervisor write access in kernel mode
#PF: error_code(0x0003) - permissions violation
PGD 12840b067 P4D 12840b067 PUD 12840d067 PMD 100323067 PTE 80010178e161
Oops: 0003 [#1] PREEMPT SMP
CPU: 1 PID: 116 Comm: modprobe Not tainted 5.11.0-rc7-00091-g34add6d4b676 #209
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
?-20190711_202441-buildvm-armv7-10.arm.fedoraproject.org-2.fc31 04/01/2014
RIP: 0010:jump_label_add_module+0x1b4/0x280
Code: 00 48 8b 43 08 a8 02 0f 85 a7 00 00 00 48 83 e0 fc 48 c7 02 00 00 00 00
48 89 42 08 48 8b 43 08 83 e0 03 48 09 c2 48 83 ca 02 <48> 89 53 08 4d 89 6e 10
49 89 6e 08 48 8b 43 08 a8 02 74 6b 48 83
RSP: 0018:b48e001b7d88 EFLAGS: 00010282
RAX:  RBX: c006eb88 RCX: 
RDX: a43a802f53c2 RSI: a41d2cc8 RDI: a41d2cc8
RBP: c004d1f0 R08: 0001 R09: 0012
R10: 1000 R11: a43a816d9001 R12: c004d5b0
R13: c004ea00 R14: a43a802f53a0 R15: c004d1f8
FS:  019f53c0() GS:a43abbc8() knl GS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: c006eb90 CR3: 0001016fe003 CR4: 00060ee0
Call Trace:
 jump_label_module_notify+0x53/0x90
 blocking_notifier_call_chain_robust+0x6c/0xd0
 load_module+0x58e/0x810
 __do_sys_init_module+0x115/0x160
 do_syscall_64+0x2d/0x70
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x55ce39
Code: 0c 00 b8 ca 00 00 00 0f 05 eb a5 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48
89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01
c3 48 c7 c1 e0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:7ffc3a5e37c8 EFLAGS: 0246 ORIG_RAX: 00af
RAX: ffda RBX:  RCX: 0055ce39
RDX: 006042ca RSI: 00042078 RDI: 7fb66fff7010
RBP: 7fb66fff7010 R08: 01a0b890 R09: 00042078
R10: 0007 R11: 0246 R12: 006042ca
R13:  R14: 01a08054 R15: 7fb66ffd6ad0
Modules linked in: mei_me(+) mei
CR2: c006eb90
---[ end trace d7a0c94b086625bf ]---

Seemingly related linker warnings are in form of:

...
x86_64-pc-linux-gnu-ld: warning: orphan section `.data.event_kfree_skb' from
`net/core/net-traces.o' being placed in section `.data.event_kfree_skb'
x86_64-pc-linux-gnu-ld: warning: orphan section `.data.event_bpf_test_finish'
from `net/bpf/test_run.o' being placed in section `.data.event_bpf_test_finish'
x86_64-pc-linux-gnu-ld: warning: orphan section `.data.event_fib6_table_lookup'
from `net/ipv6/route.o' being placed in section `.data.event_fib6_table_lookup'
...

These appeared after gcc-10 switch. gcc-10 seems to be very eager at placing
things to their own sections:

Minimal example:

$ cat net-traces.c
  struct s {
void *print_fmt;
  };
  struct s print_fmt_napi_poll[1];
  __attribute__((__used__)) struct s event_napi_poll = {print_fmt_napi_poll};


Note the
.section.data.event_napi_poll,"awR"
vs
.data
in:

$ gcc-11.0.0 -fno-PIE -S net-traces.c -fno-ident && cat net-traces.s
.file   "net-traces.c"
.text
.globl  print_fmt_napi_poll
.bss
.align 8
.type   print_fmt_napi_poll, @object
.size   print_fmt_napi_poll, 8
print_fmt_napi_poll:
.zero   8
.globl  event_napi_poll
.section.data.event_napi_poll,"awR"
.align 8
.type   event_napi_poll, @object
.size   event_napi_poll, 8
event_napi_poll:
.quad   print_fmt_napi_poll
.section.note.GNU-stack

[Bug gas/27412] Suspicious "setting incorrect section attributes for .note.Linux" warnings on linux kernel

2021-02-13 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27412

H.J. Lu  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #3 from H.J. Lu  ---
A patch is posted at

https://sourceware.org/pipermail/binutils/2021-February/115343.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/27412] Suspicious "setting incorrect section attributes for .note.Linux" warnings on linux kernel

2021-02-13 Thread slyfox at inbox dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=27412

--- Comment #4 from Sergei Trofimovich  ---
(In reply to H.J. Lu from comment #3)
> A patch is posted at
> 
> https://sourceware.org/pipermail/binutils/2021-February/115343.html

Works for me. Thank you!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/27415] New: eZ80 relocation computation fails unexpectedly

2021-02-13 Thread stp+sw334 at bje dot id.au
https://sourceware.org/bugzilla/show_bug.cgi?id=27415

Bug ID: 27415
   Summary: eZ80 relocation computation fails unexpectedly
   Product: binutils
   Version: 2.36.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gas
  Assignee: unassigned at sourceware dot org
  Reporter: stp+sw334 at bje dot id.au
  Target Milestone: ---

The test case `z80_reloc.s` tests a variety of shift and mask expressions
involving undefined symbols. Several expressions I would expect to work do not:

.assume adl=1
ld hl, data24 >> 8

Should produce:
   0:   21 00 00 00 ld hl,0x
1: r_word1  data24

Or possibly as r_byte1 and r_byte2 at 1: and 2: respectively.

dw data24 >> 8

Should produce:
0: 00 00
  0: r_word1 data24

Instead, these expressions result in an error:

Error: invalid operands (*UND* and *ABS* sections) for `>>'

This may be a documentation fault where `BFD_RELOC_Z80_WORD1` is described as
"Highest 16 bits of multibyte (32 or 24 bit) value.", but is only used as the
highest 16 bits of a 32 bit value.

-- 
You are receiving this mail because:
You are on the CC list for the bug.