Script to reproduce attached.  For aarch64, the `_bss_end` symbol is correctly after the bss section; for risc-V the BSS symbol 'd' appears _after_  `_bss_end`.  GNU binutils links correctly.
Found in version 1.18

```
#!/bin/sh
TARGET="-target riscv64 -march=rv64imac -mabi=lp64 -nostdlib"
#TARGET="-target aarch64 -nostdlib"

cat > a.c <<\EOF
int a; /* in bss */
char _stack[4096];
extern int b(void);
int main()
{
   a = b();
   return a;
}
EOF

cat > b.c <<\EOF
int d; /* in bss */
int b() {
   d += 1;
   return d;
}
EOF

cat > script.ld <<\EOF
PHDRS
{
    text PT_LOAD;
    data PT_LOAD;
}

ENTRY(_start);

SECTIONS
{
    . = 0x200000;

    .text :
    {
        _text = .;
        *(.text.start)
        *(.text*)
        *(.rodata)
        _text_end = .;
    } :text

    . = ALIGN(0x1000);
    .bss :
    {
        _bss = .;
        *(.bss)
        *(COMMON)
        . = ALIGN(4);
        _bss_end = .;
    } :data
}

EOF

# cat > crt0.s <<\EOF
# .extern main

# .section ".text.start"

# .global _start;
# .type _start, %function;
# _start:
#     ldr x1, =_stack + 0xff0
#     mov sp, x1
#     b main
# EOF
cat > crt0.s <<\EOF
.extern main

.section ".text.start"

.global _start;
.type _start, %function;
_start:
    la s1, (_stack + 0xff0)
    mv sp, s1
    j main
EOF

clang ${TARGET} -ffreestanding -c a.c
clang ${TARGET} -ffreestanding -c b.c
clang ${TARGET} -c crt0.s -o crt0.o
ld.lld -x -o a.elf crt0.o a.o b.o -T script.ld

nm -n a.elf
```
ld.lld risc-V does not merge BSS sections properly.
This is a GitHub Issue
repo:llvm-project
owner:llvm
Title : ld.lld risc-V does not merge BSS sections properly.
Issue date:

--- start body ---
Script to reproduce attached.  For aarch64, the `_bss_end` symbol is correctly after the bss section; for risc-V the BSS symbol 'd' appears _after_  `_bss_end`.  GNU binutils links correctly.
Found in version 1.18

```
#!/bin/sh
TARGET="-target riscv64 -march=rv64imac -mabi=lp64 -nostdlib"
#TARGET="-target aarch64 -nostdlib"

cat > a.c <<\EOF
int a; /* in bss */
char _stack[4096];
extern int b(void);
int main()
{
   a = b();
   return a;
}
EOF

cat > b.c <<\EOF
int d; /* in bss */
int b() {
   d += 1;
   return d;
}
EOF

cat > script.ld <<\EOF
PHDRS
{
    text PT_LOAD;
    data PT_LOAD;
}

ENTRY(_start);

SECTIONS
{
    . = 0x200000;

    .text :
    {
        _text = .;
        *(.text.start)
        *(.text*)
        *(.rodata)
        _text_end = .;
    } :text

    . = ALIGN(0x1000);
    .bss :
    {
        _bss = .;
        *(.bss)
        *(COMMON)
        . = ALIGN(4);
        _bss_end = .;
    } :data
}

EOF

# cat > crt0.s <<\EOF
# .extern main

# .section ".text.start"

# .global _start;
# .type _start, %function;
# _start:
#     ldr x1, =_stack + 0xff0
#     mov sp, x1
#     b main
# EOF
cat > crt0.s <<\EOF
.extern main

.section ".text.start"

.global _start;
.type _start, %function;
_start:
    la s1, (_stack + 0xff0)
    mv sp, s1
    j main
EOF

clang ${TARGET} -ffreestanding -c a.c
clang ${TARGET} -ffreestanding -c b.c
clang ${TARGET} -c crt0.s -o crt0.o
ld.lld -x -o a.elf crt0.o a.o b.o -T script.ld

nm -n a.elf
```
--- end body ---
