[PATCH] D43228: [ELF] Allow redefining LMA for a section inside a segment.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 19 21:49:47 PST 2018


Hi Rafael,

GNU ld's doc has a nice example of this https://sourceware.org/binutils/docs/ld/Output-Section-LMA.html.

For a ROM image, everything goes in one big chunk. There are linker script symbols which help to find where the blocks, which to be copied to the actual memory, are located.

There are other methods, too. For example, you might have a starting block with a well-known size, which copies everything after it to the right locations.

Best Regards,
Igor Kudrin
C++ Developer, Access Softek, Inc.

________________________________________
From: Rafael Avila de Espindola <rafael.espindola at gmail.com>
Sent: Tuesday, February 20, 2018 11:25 AM
To: reviews+D43228+public+3f65b968bcd3310a at reviews.llvm.org; Igor Kudrin; ruiu at google.com
Cc: Evgeny Leviant; George Rimar; emaste at freebsd.org; llvm-commits at lists.llvm.org; arichardson.kde at gmail.com; pshung807 at gmail.com; adhemerval.zanella at linaro.org
Subject: Re: [PATCH] D43228: [ELF] Allow redefining LMA for a section inside a segment.

Two sections in the same PT_LOAD cannot possibly have different deltas
between physical and virtual addresses. How would that be represented at
runtime?

Cheers,
Rafael


Igor Kudrin via Phabricator <reviews at reviews.llvm.org> writes:

> ikudrin added a comment.
>
> I don't see anything that violates the specs. With this patch, the offset of a segment (`p_offset`) is still congruent to its virtual address (`p_vaddr`), modulo page size. This rule is enforced in lines 1850-1852 of `ELF/Writer.cpp`:
>
>   if (Cmd == First)
>     return alignTo(Off, std::max<uint64_t>(Cmd->Alignment, Config->MaxPageSize),
>                    Cmd->Addr);
>
> and I didn't touch them.
>
> The description for AT output section attribute says that it defines a load address of the section and that this feature is designed to simplify creating a ROM image. This is exactly what we use it for. https://sourceware.org/binutils/docs/ld/Output-Section-LMA.html
>
> If there are no prescribed program headers in a linker script, the linker creates a new segment on each section with customized LMA, and this is OK and expected (https://reviews.llvm.org/D43284). But in case of explicitly defined segments, we, in fact, ignore some of AT directives. And this contradicts the user's intention.
>
>
> https://reviews.llvm.org/D43228


More information about the llvm-commits mailing list