forked from OSchip/llvm-project
parent
37d1aa715a
commit
0c501df3de
|
@ -630,8 +630,6 @@ DefaultLayout<ELFT>::mergeSimilarSections() {
|
|||
template <class ELFT> void DefaultLayout<ELFT>::assignSectionsToSegments() {
|
||||
ScopedTask task(getDefaultDomain(), "assignSectionsToSegments");
|
||||
ELFLinkingContext::OutputMagic outputMagic = _context.getOutputMagic();
|
||||
// TODO: Do we want to give a chance for the targetHandlers
|
||||
// to sort segments in an arbitrary order?
|
||||
// sort the sections by their order as defined by the layout
|
||||
std::stable_sort(_sections.begin(), _sections.end(),
|
||||
[](Chunk<ELFT> *A, Chunk<ELFT> *B) {
|
||||
|
|
|
@ -519,18 +519,17 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
if (((newAddr - curAddr) > this->_context.getPageSize()) &&
|
||||
(_outputMagic != ELFLinkingContext::OutputMagic::NMAGIC &&
|
||||
_outputMagic != ELFLinkingContext::OutputMagic::OMAGIC)) {
|
||||
slice = nullptr;
|
||||
// TODO: use std::find here
|
||||
for (auto s : slices()) {
|
||||
if (s->startSection() == startSection) {
|
||||
slice = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!slice) {
|
||||
auto sliceIter =
|
||||
std::find_if(_segmentSlices.begin(), _segmentSlices.end(),
|
||||
[startSection](SegmentSlice<ELFT> *s) -> bool {
|
||||
return s->startSection() == startSection;
|
||||
});
|
||||
if (sliceIter == _segmentSlices.end()) {
|
||||
slice = new (_segmentAllocate.Allocate<SegmentSlice<ELFT>>())
|
||||
SegmentSlice<ELFT>();
|
||||
_segmentSlices.push_back(slice);
|
||||
} else {
|
||||
slice = (*sliceIter);
|
||||
}
|
||||
slice->setStart(startSection);
|
||||
slice->setSections(make_range(startSectionIter, si));
|
||||
|
@ -573,18 +572,16 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
}
|
||||
currSection++;
|
||||
}
|
||||
slice = nullptr;
|
||||
for (auto s : slices()) {
|
||||
// TODO: add std::find
|
||||
if (s->startSection() == startSection) {
|
||||
slice = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!slice) {
|
||||
auto sliceIter = std::find_if(_segmentSlices.begin(), _segmentSlices.end(),
|
||||
[startSection](SegmentSlice<ELFT> *s) -> bool {
|
||||
return s->startSection() == startSection;
|
||||
});
|
||||
if (sliceIter == _segmentSlices.end()) {
|
||||
slice = new (_segmentAllocate.Allocate<SegmentSlice<ELFT>>())
|
||||
SegmentSlice<ELFT>();
|
||||
_segmentSlices.push_back(slice);
|
||||
} else {
|
||||
slice = (*sliceIter);
|
||||
}
|
||||
slice->setStart(startSection);
|
||||
slice->setVirtualAddr(curSliceAddress);
|
||||
|
|
Loading…
Reference in New Issue