[PATCH v1] LoongArch: Add support for <b ".L1"> and <beq, $t0, $t1, ".L1">

Alan Modra amodra@gmail.com
Thu Dec 14 01:36:49 GMT 2023


On Sun, Dec 10, 2023 at 05:41:32PM +0800, mengqinggang wrote:
> Support symbol names enclosed in double quotation marks.

> --- a/opcodes/loongarch-coder.c
> +++ b/opcodes/loongarch-coder.c
> @@ -264,6 +264,13 @@ loongarch_split_args_by_comma (char *args, const char *arg_strs[])
>  	else
>  	  *args = '\0', arg_strs[num++] = args + 1;
>        }
> +
> +  if (*(args-1) == '"')
> +    {
> +      *(args-1) = '\0';
> +      arg_strs[num-1] = arg_strs[num-1] + 1;
> +    }
> +
>    arg_strs[num] = NULL;
>    return num;
>  }

This results in buffer overflows running the testsuite.

/build/gas-san/loongarch32-elf/gas/testsuite/../../binutils/objdump  -dr tmpdir/64_pcrel.o > tmpdir/dump.out
Executing on host: sh -c {/build/gas-san/loongarch32-elf/gas/testsuite/../../binutils/objdump  -dr tmpdir/64_pcrel.o > tmpdir/dump.out 2>dump.tmp}  /dev/null  (timeout = 300)
spawn [open ...]
exited abnormally with 1, output:=================================================================
==3602547==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000006f at pc 0x5600d00b56c0 bp 0x7ffe37855240 sp 0x7ffe37855230
READ of size 1 at 0x60200000006f thread T0
    #0 0x5600d00b56bf in loongarch_split_args_by_comma /home/alan/src/binutils-gdb/opcodes/loongarch-coder.c:268

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list