Skip to content

[lld] LLD handles strings and their substrings in .rodata sections differently than the gnu ld linker. #121182

Closed as not planned
@Zhenhang1213

Description

@Zhenhang1213

demo:

#include <stdio.h>

void func1() {
    printf("Hello, World!\n");
}

#include <stdio.h>

void func2() {
    printf("123 Hello, World!\n");
}

int main(){
        func1();
        func2();
        return 0;
}

clang demo.c -o a.out -fuse-ld=ld
clang demo.c -o a.out -fuse-ld=lld

lld:

Contents of section .rodata:
 05f8 01000200 48656c6c 6f2c2057 6f726c64  ....Hello, World
 0608 210a0031 32332048 656c6c6f 2c20576f  !..123 Hello, Wo
 0618 726c6421 0a00                        rld!..

ld:

Contents of section .rodata:
 07ec 01000200 31323320 48656c6c 6f2c2057  ....123 Hello, W
 07fc 6f726c64 210a00                      orld!..

GNU ld version is 2.41

for the codesize, lld could support this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    lldquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions