Hello Nick,

I found the e-mail address on an old binutils doc page, and
unfortunately I didn't realize how old it was. But true, the current
doc page address is present in the rpm info, next time I will register.

I wanted to know how exactly gcc translates such expressions like
n * 0x1001. People are talking about multiplication being not slower
than any other arithmetic operation on modern processors, but in fact I
got the code (n << 12) + n, no matter which form I used in the C
source. OK, it was with -O0, but it would be quite illogical to
translate multiplication to shift on -O0, and to multiplication on -O3.

Not frequently, but similar question occur from time to time. 

The default assembly listing page width is too narrow, I don't like
reading folded source lines, truncated lines are even worse (or
better?). Even 132 characters are not enough, but rhs-width wouldn't
work with whatever sensible width.

I am attaching the asm source. I applied the same command line, except
-c replaced by -S.

br
PK







On Thu, 2024-09-26 at 16:33 +0100, Nick Clifton wrote:
> Hi Peter,
> 
> > gcc -c -O1 -ggdb -masm=intel -Wa,-acdhlgn=gfp_library.lst -Wa,--
> > listing-lhs-width=4,--listing-rhs-width=132 -o gfp_library.o
> > gfp_library.c
> 
> In the future if you have other bugs like this to report, please
> could you capture the compiler's assembler output and provide that
> as the test file, rather than the C source ?  The reason being that
> this eliminates one step in the process and it means that I do not
> need to have exactly the same version of gcc installed on my machine.
> 
> Also - it really helps if you can file a bug report with the binutils
> bugzilla system:
> https://sourceware.org/bugzilla/enter_bug.cgi?product=binutils
> 
> This lets us track the bug and any discussion about it.  Plus we can
> put comments in the code referring to the bug's PR number and even
> create
> new tests that refer back to the bug report as well.
> 
> As it happens however I am able to reproduce the problem locally,
> and the first thing that occurs to be is to wonder why you are
> capturing an assembler listing ?  And given that it is needed, why
> do you need a limit on the width of the source code in the listing ?
> 
> The problem is obviously in the listing code, which is old and
> crufty.
> I am taking a look however and I may be able to find a solution.
> 
> Cheers
>    Nick
> 

        .file   "gfp_library.c"
        .intel_syntax noprefix
        .text
.Ltext0:
        .file 0 "/home/peter/tmp" "gfp_library.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "/usr/lib64/libc.so.6"
.LC1:
        .string "realloc"
        .text
        .globl  gfp_lib_init
        .type   gfp_lib_init, @function
gfp_lib_init:
.LFB1:
        .file 1 "gfp_library.c"
        .loc 1 20 1 view -0
        .cfi_startproc
        sub     rsp, 8
        .cfi_def_cfa_offset 16
        .loc 1 21 3 view .LVU1
        .loc 1 21 18 is_stmt 0 view .LVU2
        mov     esi, 1
        mov     edi, OFFSET FLAT:.LC0
        call    dlopen
.LVL0:
        mov     rdi, rax
        .loc 1 21 16 discriminator 1 view .LVU3
        mov     QWORD PTR libc_so[rip], rax
        .loc 1 23 12 view .LVU4
        mov     eax, 1
        .loc 1 21 6 discriminator 1 view .LVU5
        test    rdi, rdi
        je      .L1
.LBB4:
.LBI4:
        .loc 1 13 20 is_stmt 1 view .LVU6
.LBB5:
        .loc 1 15 3 view .LVU7
        .loc 1 15 24 is_stmt 0 view .LVU8
        mov     esi, OFFSET FLAT:.LC1
        call    dlsym
.LVL1:
.LBE5:
.LBE4:
        .loc 1 21 48 discriminator 1 view .LVU9
        test    rax, rax
        sete    al
        movzx   eax, al
.L1:
        .loc 1 26 1 view .LVU10
        add     rsp, 8
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc
.LFE1:
        .size   gfp_lib_init, .-gfp_lib_init
        .local  libc_so
        .comm   libc_so,8,8
.Letext0:
        .file 2 "/usr/lib/gcc/x86_64-redhat-linux/14/include/stddef.h"
        .file 3 "/usr/include/dlfcn.h"
        .section        .debug_info,"",@progbits
.Ldebug_info0:
        .long   0x16c
        .value  0x5
        .byte   0x1
        .byte   0x8
        .long   .Ldebug_abbrev0
        .uleb128 0x9
        .long   .LASF8
        .byte   0x1d
        .long   .LASF0
        .long   .LASF1
        .quad   .Ltext0
        .quad   .Letext0-.Ltext0
        .long   .Ldebug_line0
        .uleb128 0x3
        .long   .LASF2
        .byte   0x2
        .byte   0xd6
        .byte   0x17
        .long   0x3a
        .uleb128 0x4
        .byte   0x8
        .byte   0x7
        .long   .LASF4
        .uleb128 0x3
        .long   .LASF3
        .byte   0x1
        .byte   0x7
        .byte   0xf
        .long   0x4d
        .uleb128 0xa
        .long   0x61
        .long   0x61
        .uleb128 0x1
        .long   0x61
        .uleb128 0x1
        .long   0x2e
        .byte   0
        .uleb128 0xb
        .byte   0x8
        .uleb128 0x5
        .long   0x61
        .uleb128 0xc
        .long   .LASF9
        .byte   0x1
        .byte   0x9
        .byte   0x14
        .long   0x61
        .uleb128 0x9
        .byte   0x3
        .quad   libc_so
        .uleb128 0xd
        .long   .LASF10
        .byte   0x1
        .byte   0xa
        .byte   0x14
        .long   0x8a
        .uleb128 0x6
        .long   0x41
        .uleb128 0x7
        .long   .LASF6
        .byte   0x40
        .long   0x61
        .long   0xa8
        .uleb128 0x1
        .long   0x63
        .uleb128 0x1
        .long   0xad
        .byte   0
        .uleb128 0x6
        .long   0xb9
        .uleb128 0x5
        .long   0xa8
        .uleb128 0x4
        .byte   0x1
        .byte   0x6
        .long   .LASF5
        .uleb128 0xe
        .long   0xb2
        .uleb128 0x7
        .long   .LASF7
        .byte   0x38
        .long   0x61
        .long   0xd7
        .uleb128 0x1
        .long   0xa8
        .uleb128 0x1
        .long   0xd7
        .byte   0
        .uleb128 0xf
        .byte   0x4
        .byte   0x5
        .string "int"
        .uleb128 0x10
        .long   .LASF11
        .byte   0x1
        .byte   0x13
        .byte   0x5
        .long   0xd7
        .quad   .LFB1
        .quad   .LFE1-.LFB1
        .uleb128 0x1
        .byte   0x9c
        .long   0x162
        .uleb128 0x11
        .long   0x162
        .quad   .LBI4
        .byte   .LVU6
        .quad   .LBB4
        .quad   .LBE4-.LBB4
        .byte   0x1
        .byte   0x16
        .byte   0x17
        .long   0x141
        .uleb128 0x8
        .quad   .LVL1
        .long   0x8f
        .uleb128 0x2
        .uleb128 0x1
        .byte   0x54
        .uleb128 0x9
        .byte   0x3
        .quad   .LC1
        .byte   0
        .byte   0
        .uleb128 0x8
        .quad   .LVL0
        .long   0xbe
        .uleb128 0x2
        .uleb128 0x1
        .byte   0x55
        .uleb128 0x9
        .byte   0x3
        .quad   .LC0
        .uleb128 0x2
        .uleb128 0x1
        .byte   0x54
        .uleb128 0x1
        .byte   0x31
        .byte   0
        .byte   0
        .uleb128 0x12
        .long   .LASF12
        .byte   0x1
        .byte   0xd
        .byte   0x14
        .long   0x8a
        .byte   0x1
        .byte   0
        .section        .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
        .uleb128 0x1
        .uleb128 0x5
        .byte   0
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x2
        .uleb128 0x49
        .byte   0
        .uleb128 0x2
        .uleb128 0x18
        .uleb128 0x7e
        .uleb128 0x18
        .byte   0
        .byte   0
        .uleb128 0x3
        .uleb128 0x16
        .byte   0
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0xb
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0xb
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x4
        .uleb128 0x24
        .byte   0
        .uleb128 0xb
        .uleb128 0xb
        .uleb128 0x3e
        .uleb128 0xb
        .uleb128 0x3
        .uleb128 0xe
        .byte   0
        .byte   0
        .uleb128 0x5
        .uleb128 0x37
        .byte   0
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x6
        .uleb128 0xf
        .byte   0
        .uleb128 0xb
        .uleb128 0x21
        .sleb128 8
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x7
        .uleb128 0x2e
        .byte   0x1
        .uleb128 0x3f
        .uleb128 0x19
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0x21
        .sleb128 3
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0x21
        .sleb128 14
        .uleb128 0x27
        .uleb128 0x19
        .uleb128 0x49
        .uleb128 0x13
        .uleb128 0x3c
        .uleb128 0x19
        .uleb128 0x1
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x8
        .uleb128 0x48
        .byte   0x1
        .uleb128 0x7d
        .uleb128 0x1
        .uleb128 0x7f
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x9
        .uleb128 0x11
        .byte   0x1
        .uleb128 0x25
        .uleb128 0xe
        .uleb128 0x13
        .uleb128 0xb
        .uleb128 0x3
        .uleb128 0x1f
        .uleb128 0x1b
        .uleb128 0x1f
        .uleb128 0x11
        .uleb128 0x1
        .uleb128 0x12
        .uleb128 0x7
        .uleb128 0x10
        .uleb128 0x17
        .byte   0
        .byte   0
        .uleb128 0xa
        .uleb128 0x15
        .byte   0x1
        .uleb128 0x27
        .uleb128 0x19
        .uleb128 0x49
        .uleb128 0x13
        .uleb128 0x1
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0xb
        .uleb128 0xf
        .byte   0
        .uleb128 0xb
        .uleb128 0xb
        .byte   0
        .byte   0
        .uleb128 0xc
        .uleb128 0x34
        .byte   0
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0xb
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0xb
        .uleb128 0x49
        .uleb128 0x13
        .uleb128 0x2
        .uleb128 0x18
        .byte   0
        .byte   0
        .uleb128 0xd
        .uleb128 0x34
        .byte   0
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0xb
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0xb
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0xe
        .uleb128 0x26
        .byte   0
        .uleb128 0x49
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0xf
        .uleb128 0x24
        .byte   0
        .uleb128 0xb
        .uleb128 0xb
        .uleb128 0x3e
        .uleb128 0xb
        .uleb128 0x3
        .uleb128 0x8
        .byte   0
        .byte   0
        .uleb128 0x10
        .uleb128 0x2e
        .byte   0x1
        .uleb128 0x3f
        .uleb128 0x19
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0xb
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0xb
        .uleb128 0x27
        .uleb128 0x19
        .uleb128 0x49
        .uleb128 0x13
        .uleb128 0x11
        .uleb128 0x1
        .uleb128 0x12
        .uleb128 0x7
        .uleb128 0x40
        .uleb128 0x18
        .uleb128 0x7a
        .uleb128 0x19
        .uleb128 0x1
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x11
        .uleb128 0x1d
        .byte   0x1
        .uleb128 0x31
        .uleb128 0x13
        .uleb128 0x52
        .uleb128 0x1
        .uleb128 0x2138
        .uleb128 0xb
        .uleb128 0x11
        .uleb128 0x1
        .uleb128 0x12
        .uleb128 0x7
        .uleb128 0x58
        .uleb128 0xb
        .uleb128 0x59
        .uleb128 0xb
        .uleb128 0x57
        .uleb128 0xb
        .uleb128 0x1
        .uleb128 0x13
        .byte   0
        .byte   0
        .uleb128 0x12
        .uleb128 0x2e
        .byte   0
        .uleb128 0x3
        .uleb128 0xe
        .uleb128 0x3a
        .uleb128 0xb
        .uleb128 0x3b
        .uleb128 0xb
        .uleb128 0x39
        .uleb128 0xb
        .uleb128 0x27
        .uleb128 0x19
        .uleb128 0x49
        .uleb128 0x13
        .uleb128 0x20
        .uleb128 0xb
        .byte   0
        .byte   0
        .byte   0
        .section        .debug_aranges,"",@progbits
        .long   0x2c
        .value  0x2
        .long   .Ldebug_info0
        .byte   0x8
        .byte   0
        .value  0
        .value  0
        .quad   .Ltext0
        .quad   .Letext0-.Ltext0
        .quad   0
        .quad   0
        .section        .debug_line,"",@progbits
.Ldebug_line0:
        .section        .debug_str,"MS",@progbits,1
.LASF4:
        .string "long unsigned int"
.LASF2:
        .string "size_t"
.LASF3:
        .string "realloc_ft"
.LASF12:
        .string "get_realloc"
.LASF9:
        .string "libc_so"
.LASF7:
        .string "dlopen"
.LASF10:
        .string "libc_realloc"
.LASF6:
        .string "dlsym"
.LASF8:
        .string "GNU C17 14.2.1 20240912 (Red Hat 14.2.1-3) -masm=intel 
-mtune=generic -march=x86-64 -ggdb -O1"
.LASF5:
        .string "char"
.LASF11:
        .string "gfp_lib_init"
        .section        .debug_line_str,"MS",@progbits,1
.LASF1:
        .string "/home/peter/tmp"
.LASF0:
        .string "gfp_library.c"
        .ident  "GCC: (GNU) 14.2.1 20240912 (Red Hat 14.2.1-3)"
        .section        .note.GNU-stack,"",@progbits

Reply via email to