Hi,
Thanks a lot for your answer. It seems lld is still the best
solution, even if it does not work "right out of the box" for
us today.
We already have a solution for the "objcopy" part (added the
required output format to llvm-objdump).
Interesting solution. Would it be much work to implement an
llvm-objcopy that only supports -O binary? I plan to fully implement
objcopy one of these days, but having just that as a start would be
very useful.
The ScriptLayout class seems to be empty for now (on the master
branch at least), but we do not need linker scripts today.
All that is required for now is to be able to assign a fixed
address to a few atoms (the ones that will hold the reset &
interrupt vectors) and place code/data sections in code/data
memory (so we can simulate generated code and fix and optimize
our LLVM target).
I guess that can be done by adapting the DefaultLayout code in
our own Layout class, but any hint or documentation about how
There are two ways for getting this to work :-
(a)
There is a requirement that an output section could have a fixed address by using --section-start.
The way I thought to go about this was to have a structure, called
class AtomSectionAttributes {
virtual StringRef getOutputSectionName() = 0;
};
class MergedSectionAttributes {
virtual uint64_t getAddress() = 0;
virtual StringRef name() = 0;
virtual bool needsNewProgramHeader() = 0;
};
When the user says -section-start .text = 0xf000000, what lld could do is create a mergeSection upfront, and set the MergedSectionAttributes information.
The assignVirtualAddress would change by looking at the mergedSectionAttribute to set the appropriate virtualaddress.
(b)
The hierarchy that we have is as below :-
DefaultLayout
>
ScriptLayout
>
TargetLayout
All the ELF writers have a TargetLayout object contained in them.
Use a linker script, you need to parse the SECTION command, and override the following functions in the ScriptLayout class to take care of the users intention specified in the linker script.
getSectionOrder
getSectionName
hasOutputSecgment
addAtom
assignVirtualAddress
assignFileOffsets
Does this help ?
-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation