| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
llvm-svn: 308297
|
|
|
|
|
|
|
|
|
|
|
| |
The comment at the top of compareByFilePosition indicates that it relies
on stable_sort to preserve the order of synthetic sections. We were
using sort instead of stable_sort, however, leading to incorrect
synthetic section ordering.
Differential Revision: https://reviews.llvm.org/D35473
llvm-svn: 308207
|
|
|
|
|
|
|
|
| |
Functions declared in Strings.h should provide generic string operations
for the linker, but some of them are too specific to some features. This
patch moves them to the location where they are used.
llvm-svn: 307949
|
|
|
|
|
|
|
|
|
|
|
|
| |
Patch removes restriction about moving location counter
backwards outside of output sections declarations.
That may be useful for some apps relying on such scripts,
known example is linux kernel.
Differential revision: https://reviews.llvm.org/D34977
llvm-svn: 307794
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
r307367 via D34345 split out the temporary address state used within
processCommands() and assignAddresses(). Due to the way that getSymbolValue
is used by the ScriptParser there is no way of giving the current
OutputSection to getSymbolValue() without somehow accessing the created
addressState. The suggestion was that by making a pointer that would go out
of scope we would find out by ASAN/MSAN or a crash if someone had misused
currentAddressState.
Differential Revision: https://reviews.llvm.org/D34345
llvm-svn: 307637
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The assignAddresses() function accumulates state in the LinkerScript that
prevents it from being called multiple times. This change moves the state
into a separate structure AddressState that is created at the start of the
function and disposed of at the end.
CurAddressState is used rather than passing a reference to the state as a
parameter to the functions used by assignAddresses(). This is because the
getSymbolValue function needs to be executed in the context of AddressState
but it is stored in ScriptParser when AddressState is not available.
The AddressState is also used in a limited context by processCommands()
Differential Revision: https://reviews.llvm.org/D34345
llvm-svn: 307367
|
|
|
|
|
|
|
| |
It is now just after the OutputSections are created, which is as early
as it can possibly go.
llvm-svn: 307225
|
|
|
|
| |
llvm-svn: 307217
|
|
|
|
| |
llvm-svn: 307214
|
|
|
|
|
|
| |
This is a bit simpler and avoids a walk over OutputSections.
llvm-svn: 307178
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The allocateHeaders() function is called at the end of assignAddresses(), it
decides whether the ELF header and program header table can be allocated to
a PT_LOAD program header. As the function alters state, it prevents
assignAddresses() from being called multiple times.
This change splits out the call to allocateHeaders() from assignAddresses()
this will permit assignAddresses() to be called while processing range
extension thunks without trying to allocateHeaders().
Differential Revision: https://reviews.llvm.org/D34344
llvm-svn: 307131
|
|
|
|
|
|
| |
Two more places.
llvm-svn: 307076
|
|
|
|
|
|
|
| |
* Return type changed to void, because it was unused.
* std::find_if -> llvm::find_if
llvm-svn: 307039
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch makes changes to allow sections without the SHF_ALLOC bit to be
assigned to segments in a linker script.
The assignment of output sections to segments is performed in
LinkerScript::createPhdrs. Previously, this function would bail as soon as it
encountered an output section which did not have the SHF_ALLOC bit set, thus
preventing any output section without SHF_ALLOC from being assigned to a
segment.
This restriction has now been removed from LinkerScript::createPhdrs and instead
a check for SHF_ALLOC has been added to LinkerScript::adjustSectionsAfterSorting
to not propagate program headers to sections without SHF_ALLOC which matches the
behaviour of bfd linker scripts.
Differential Revision: https://reviews.llvm.org/D34204
llvm-svn: 307013
|
|
|
|
| |
llvm-svn: 306308
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I found this while trying to build u-boot. It uses -Ttext in
combination with linker scripts.
My first reaction was to change the linker scripts to have the correct
value, but I found that it is actually quite convenient to have -Ttext
take precedence.
By having just
.text : { *(.text) }
In the script, they can define the text address in a single Makefile
and pass it to ld with -Ttext and for the C code with
-DFoo=value. Doing the same with linker scripts would require them to
be generated during the build.
llvm-svn: 305766
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds support for segment NONE in linker scripts which enables the
specification that a section should not be assigned to any segment.
Note that GNU ld does not disallow the definition of a segment named NONE, which
if defined, effectively overrides the behaviour described above. This feature
has been copied.
Differential Revision: https://reviews.llvm.org/D34203
llvm-svn: 305700
|
|
|
|
|
|
| |
We would crash before.
llvm-svn: 305615
|
|
|
|
|
|
| |
We would crash instead before.
llvm-svn: 305614
|
|
|
|
|
|
| |
We would crash instead before.
llvm-svn: 305613
|
|
|
|
| |
llvm-svn: 305601
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is probably the main patch left in unifying our intermediary
representation.
It moves the creation of default commands before section sorting. This
has the nice effect that we now have one location where we decide
where an orphan section should be placed.
Before this patch sortSections would decide the relative location of
orphan sections to other sections, but it was up to placeOrphanSection
to decide on the exact location.
We now only sort sections we created since the linker script is
already in the correct order.
llvm-svn: 305512
|
|
|
|
| |
llvm-svn: 305341
|
|
|
|
|
|
|
| |
This is similar to what we do for InputSections and makes them easier
to access.
llvm-svn: 305337
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently we do layout as if non alloc sections had an actual address
and then set it to zero. This produces a few odd results where a
symbol has an address that is inconsistent with the section address.
The simplest way to fix it is probably to just set the address earlier.
The behavior of bfd seems to be similar, but it only sets the non
alloc section address is missing from the linker script or if the
script has an explicit " : 0" setting the address of the output
section (which the default script does).
llvm-svn: 305323
|
|
|
|
| |
llvm-svn: 305156
|
|
|
|
|
|
| |
This then requires delaying a call to getHeaderSize.
llvm-svn: 304961
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is PR32351
Each output section may have a type. The type is a keyword in parentheses.
(https://sourceware.org/binutils/docs/ld/Output-Section-Type.html#Output-Section-Type)
This patch support only one type, it is NOLOAD.
If output section has such type, we force it to be SHT_NOBITS.
More details are available on a review page.
Differential revision: https://reviews.llvm.org/D33647
llvm-svn: 304925
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thunks are now generated per InputSectionDescription instead of per
OutputSection. This allows created ThunkSections to be inserted directly
into InputSectionDescription.
Changes in this patch:
- Loop over InputSectionDescriptions to find relocations to Thunks
- Generate a ThunkSection per InputSectionDescription
- Remove synchronize() as we no longer need it
- Move fabricateDefaultCommands() before createThunks
Differential Revision: https://reviews.llvm.org/D33835
llvm-svn: 304887
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When linking linux kernel LLD currently reports next errors:
ld: error: unable to evaluate expression: input section .head.text has no output section assigned
ld: error: At least one side of the expression must be absolute
ld: error: At least one side of the expression must be absolute
That does not provide file/line information and overall looks unclear.
Patch adds location information to ExprValue and that allows
to provide more clear error messages.
Differential revision: https://reviews.llvm.org/D33943
llvm-svn: 304881
|
|
|
|
|
|
|
|
|
|
|
|
| |
This creates a new library called BinaryFormat that has all of
the headers from llvm/Support containing structure and layout
definitions for various types of binary formats like dwarf, coff,
elf, etc as well as the code for identifying a file from its
magic.
Differential Revision: https://reviews.llvm.org/D33843
llvm-svn: 304864
|
|
|
|
|
|
|
|
| |
We now used the InputSectionDescriptions in
OutputSectionCommand::finalize. This will allow moving
clearOutputSections earlier.
llvm-svn: 304827
|
|
|
|
|
|
|
| |
This removes a mapping from OutputSection to OutputSectionCommand and
is another step in moving clearOutputSections earlier.
llvm-svn: 304821
|
|
|
|
|
|
| |
That addresses port commit comments for https://reviews.llvm.org/D33646
llvm-svn: 304777
|
|
|
|
|
|
|
| |
This allows us to remove the PageAlign field. It will also allow
moving fabricateDefaultCommands earlier.
llvm-svn: 304513
|
|
|
|
| |
llvm-svn: 304511
|
|
|
|
|
|
|
| |
This removes a call to getCmd and allows us to move
clearOutputSections earlier.
llvm-svn: 304439
|
|
|
|
|
|
| |
Also needed to move clearOutputSections earlier.
llvm-svn: 304420
|
|
|
|
|
|
|
|
|
|
|
| |
We were looking up sections by name during expression evaluation. By
keeping track of forward declarations we can do the lookup during
script parsing.
Doing the lookup earlier will be more efficient when assignAddresses
is run twice and removes two uses of OutputSections.
llvm-svn: 304381
|
|
|
|
|
|
|
| |
Another step into merging the linker script and non linker script code
paths.
llvm-svn: 304339
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before InputSectionBase had an OutputSection pointer, but that was not
always valid. For example, if it was a merge section one actually had
to look at MergeSec->OutSec.
This was brittle and caused bugs like the one fixed by r304260.
We now have a single Parent pointer that points to an OutputSection
for InputSection, but to a SyntheticSection for merge sections and
.eh_frame. This makes it impossible to accidentally access an invalid
OutSec.
llvm-svn: 304338
|
|
|
|
| |
llvm-svn: 304334
|
|
|
|
|
|
|
| |
By the time we get here all live sections should have been combined
into InputSections.
llvm-svn: 304243
|
|
|
|
| |
llvm-svn: 304240
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I found that during visual inspection of code while wrote different patch.
Script in testcase probably have nothing common with real life, but
we segfault currently using it.
If output section is known NOBITS, there is no need to create
writers threads for doing nothing or proccess any filler logic that
is useless here. We can just early return, that is what this patch do.
DIfferential revision: https://reviews.llvm.org/D33646
llvm-svn: 304192
|
|
|
|
|
|
|
|
|
| |
InputSections may contain MergeInputSection members which trigger
a segmentation fault when trying to cast them to InputSection.
Differential Revision: https://reviews.llvm.org/D33628
llvm-svn: 304189
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While the following expression is handled fine:
PROVIDE_HIDDEN(newsym = oldsym + address);
The following expression triggers an error because the expression
is evaluated as absolute:
PROVIDE_HIDDEN(newsym = ALIGN(oldsym, CONSTANT(MAXPAGESIZE)) + address);
To avoid this error, we use late evaluation for ALIGN by making the
alignment an attribute of the expression itself.
Differential Revision: https://reviews.llvm.org/D33629
llvm-svn: 304185
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reduces how many times we have to map from OutputSection to
OutputSectionCommand. It is a required step to moving
clearOutputSections earlier.
In order to always use writeTo in OutputSectionCommand we have to call
fabricateDefaultCommands for -r links and move section compression
after it.
llvm-svn: 303784
|
|
|
|
|
|
|
|
| |
dummy sections.
Fix for PR33029.
llvm-svn: 303770
|
|
|
|
|
|
|
|
|
| |
By the time we get to linker scripts, all special InputSectionBase
should have been combined into synthetic sections, which are a type of
InputSection. The net result is that we can use InputSection in a few
places that were using InputSectionBase.
llvm-svn: 303702
|