mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-11 08:29:25 +00:00
Fix pr20793.
With this patch the third field of llvm.global_ctors is also used on ELF. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -360,42 +360,66 @@ TargetLoweringObjectFileELF::getSectionForConstant(SectionKind Kind,
|
||||
|
||||
const MCSection *TargetLoweringObjectFileELF::getStaticCtorSection(
|
||||
unsigned Priority, const MCSymbol *KeySym) const {
|
||||
// The default scheme is .ctor / .dtor, so we have to invert the priority
|
||||
// numbering.
|
||||
if (Priority == 65535)
|
||||
return StaticCtorSection;
|
||||
std::string Name;
|
||||
unsigned Type;
|
||||
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
|
||||
SectionKind Kind = SectionKind::getDataRel();
|
||||
StringRef COMDAT = KeySym ? KeySym->getName() : "";
|
||||
|
||||
if (KeySym)
|
||||
Flags |= ELF::SHF_GROUP;
|
||||
|
||||
if (UseInitArray) {
|
||||
std::string Name = std::string(".init_array.") + utostr(Priority);
|
||||
return getContext().getELFSection(Name, ELF::SHT_INIT_ARRAY,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
Name = ".init_array";
|
||||
if (Priority != 65535) {
|
||||
Name += '.';
|
||||
Name += utostr(Priority);
|
||||
}
|
||||
Type = ELF::SHT_INIT_ARRAY;
|
||||
} else {
|
||||
std::string Name = std::string(".ctors.") + utostr(65535 - Priority);
|
||||
return getContext().getELFSection(Name, ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
// The default scheme is .ctor / .dtor, so we have to invert the priority
|
||||
// numbering.
|
||||
Name = std::string(".ctors");
|
||||
if (Priority != 65535) {
|
||||
Name += '.';
|
||||
Name += utostr(65535 - Priority);
|
||||
}
|
||||
Type = ELF::SHT_PROGBITS;
|
||||
}
|
||||
|
||||
return getContext().getELFSection(Name, Type, Flags, Kind, 0, COMDAT);
|
||||
}
|
||||
|
||||
const MCSection *TargetLoweringObjectFileELF::getStaticDtorSection(
|
||||
unsigned Priority, const MCSymbol *KeySym) const {
|
||||
// The default scheme is .ctor / .dtor, so we have to invert the priority
|
||||
// numbering.
|
||||
if (Priority == 65535)
|
||||
return StaticDtorSection;
|
||||
std::string Name;
|
||||
unsigned Type;
|
||||
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE;
|
||||
SectionKind Kind = SectionKind::getDataRel();
|
||||
StringRef COMDAT = KeySym ? KeySym->getName() : "";
|
||||
|
||||
if (KeySym)
|
||||
Flags |= ELF::SHF_GROUP;
|
||||
|
||||
if (UseInitArray) {
|
||||
std::string Name = std::string(".fini_array.") + utostr(Priority);
|
||||
return getContext().getELFSection(Name, ELF::SHT_FINI_ARRAY,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
Name = ".fini_array";
|
||||
if (Priority != 65535) {
|
||||
Name += '.';
|
||||
Name += utostr(Priority);
|
||||
}
|
||||
Type = ELF::SHT_FINI_ARRAY;
|
||||
} else {
|
||||
std::string Name = std::string(".dtors.") + utostr(65535 - Priority);
|
||||
return getContext().getELFSection(Name, ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
// The default scheme is .ctor / .dtor, so we have to invert the priority
|
||||
// numbering.
|
||||
Name = ".dtors";
|
||||
if (Priority != 65535) {
|
||||
Name += '.';
|
||||
Name += utostr(65535 - Priority);
|
||||
}
|
||||
Type = ELF::SHT_PROGBITS;
|
||||
}
|
||||
|
||||
return getContext().getELFSection(Name, Type, Flags, Kind, 0, COMDAT);
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user