8000 `ALIGN_WITH_INPUT` behavior differs from ld when not using PHDRs · Issue #56 · qualcomm/eld · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ALIGN_WITH_INPUT behavior differs from ld when not using PHDRs #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jonathonpenix opened this issue Apr 22, 2025 · 0 comments
Open
Assignees

Comments

@jonathonpenix
Copy link

Creating a follow-up ticket for #53 based on the discussion there.

Reproducer of what we're seeing based on the tests in [1] and [2]:

cat > test.c << '!'
__attribute__((section(".a")))
__attribute__((aligned(64)))
int foo(void) { return 1; }

__attribute__((section(".b")))
__attribute__((aligned(128)))
int bar(void) { return 2; }
!

cat > script.t << '!'
MEMORY {
  VMA_REGION (rwx) : ORIGIN = 0x1000, LENGTH = 0x1000
  LMA_REGION (rwx) : ORIGIN = 0x3fc0, LENGTH = 0x1000
}

SECTIONS {
  .a : ALIGN_WITH_INPUT {
    begin = .;
    *(.a)
  } > VMA_REGION AT > LMA_REGION
  .b : ALIGN_WITH_INPUT {
    *(.b)
    end = .;
  } > VMA_REGION AT > LMA_REGION
}
!

clang --target=riscv32-unknown-elf -Oz -c test.c
riscv32-unknown-elf-ld.bfd -T script.t test.o -o ld.a.out
riscv-link -T script.t test.o -o eld.a.out

Output snippets:

$ llvm-objdump --headers ld.a.out
...
  1 .a                00000004 00001000 00003fc0 TEXT
  2 .b                00000004 00001080 00004040 TEXT
...
$ llvm-objdump --headers eld.a.out
...
  1 .a                00000004 00001000 00003fc0 TEXT
  2 .b                00000004 00001080 00004000 TEXT
...

I think the memcpy scenario mentioned in [1] is roughly similar to what Zephyr uses ALIGN_WITH_INPUT for, but I need to double check that. Will update here later.

Links:
[1] https://binutils.sourceware.narkive.com/MTsXxI3t/patch-ld-add-align-with-input-output-section-attribute
[2] https://archive.fosdem.org/2024/events/attachments/fosdem-2024-2340-linker-scripts-in-lld-and-how-they-compare-with-gnu-ld/slides/22752/Fosdem_linker_scripts_2024_uG7XLOI.pdf (see slide 30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0