mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Change the String<size> methods to take a fragment instead of a buffer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118709 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -214,10 +214,6 @@ namespace {
|
|||||||
Writer->Write32(W);
|
Writer->Write32(W);
|
||||||
}
|
}
|
||||||
|
|
||||||
void String8(char *buf, uint8_t Value) {
|
|
||||||
buf[0] = Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringLE16(char *buf, uint16_t Value) {
|
void StringLE16(char *buf, uint16_t Value) {
|
||||||
buf[0] = char(Value >> 0);
|
buf[0] = char(Value >> 0);
|
||||||
buf[1] = char(Value >> 8);
|
buf[1] = char(Value >> 8);
|
||||||
@ -248,25 +244,37 @@ namespace {
|
|||||||
StringBE32(buf + 4, uint32_t(Value >> 0));
|
StringBE32(buf + 4, uint32_t(Value >> 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void String16(char *buf, uint16_t Value) {
|
void String8(MCDataFragment &F, uint8_t Value) {
|
||||||
|
char buf[1];
|
||||||
|
buf[0] = Value;
|
||||||
|
F.getContents() += StringRef(buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void String16(MCDataFragment &F, uint16_t Value) {
|
||||||
|
char buf[2];
|
||||||
if (Writer->isLittleEndian())
|
if (Writer->isLittleEndian())
|
||||||
StringLE16(buf, Value);
|
StringLE16(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE16(buf, Value);
|
StringBE16(buf, Value);
|
||||||
|
F.getContents() += StringRef(buf, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void String32(char *buf, uint32_t Value) {
|
void String32(MCDataFragment &F, uint32_t Value) {
|
||||||
|
char buf[4];
|
||||||
if (Writer->isLittleEndian())
|
if (Writer->isLittleEndian())
|
||||||
StringLE32(buf, Value);
|
StringLE32(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE32(buf, Value);
|
StringBE32(buf, Value);
|
||||||
|
F.getContents() += StringRef(buf, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void String64(char *buf, uint64_t Value) {
|
void String64(MCDataFragment &F, uint64_t Value) {
|
||||||
|
char buf[8];
|
||||||
if (Writer->isLittleEndian())
|
if (Writer->isLittleEndian())
|
||||||
StringLE64(buf, Value);
|
StringLE64(buf, Value);
|
||||||
else
|
else
|
||||||
StringBE64(buf, Value);
|
StringBE64(buf, Value);
|
||||||
|
F.getContents() += StringRef(buf, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteHeader(uint64_t SectionDataSize, unsigned NumberOfSections);
|
void WriteHeader(uint64_t SectionDataSize, unsigned NumberOfSections);
|
||||||
@ -407,62 +415,29 @@ void ELFObjectWriterImpl::WriteSymbolEntry(MCDataFragment *SymtabF,
|
|||||||
uint32_t shndx,
|
uint32_t shndx,
|
||||||
bool Reserved) {
|
bool Reserved) {
|
||||||
if (ShndxF) {
|
if (ShndxF) {
|
||||||
char buf[4];
|
|
||||||
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
||||||
String32(buf, shndx);
|
String32(*ShndxF, shndx);
|
||||||
else
|
else
|
||||||
String32(buf, 0);
|
String32(*ShndxF, 0);
|
||||||
ShndxF->getContents() += StringRef(buf, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t Index = (shndx >= ELF::SHN_LORESERVE && !Reserved) ?
|
||||||
|
uint16_t(ELF::SHN_XINDEX) : shndx;
|
||||||
|
|
||||||
if (Is64Bit) {
|
if (Is64Bit) {
|
||||||
char buf[8];
|
String32(*SymtabF, name); // st_name
|
||||||
|
String8(*SymtabF, info); // st_info
|
||||||
String32(buf, name);
|
String8(*SymtabF, other); // st_other
|
||||||
SymtabF->getContents() += StringRef(buf, 4); // st_name
|
String16(*SymtabF, Index); // st_shndx
|
||||||
|
String64(*SymtabF, value); // st_value
|
||||||
String8(buf, info);
|
String64(*SymtabF, size); // st_size
|
||||||
SymtabF->getContents() += StringRef(buf, 1); // st_info
|
|
||||||
|
|
||||||
String8(buf, other);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 1); // st_other
|
|
||||||
|
|
||||||
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
|
||||||
String16(buf, ELF::SHN_XINDEX);
|
|
||||||
else
|
|
||||||
String16(buf, shndx);
|
|
||||||
|
|
||||||
SymtabF->getContents() += StringRef(buf, 2); // st_shndx
|
|
||||||
|
|
||||||
String64(buf, value);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 8); // st_value
|
|
||||||
|
|
||||||
String64(buf, size);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 8); // st_size
|
|
||||||
} else {
|
} else {
|
||||||
char buf[4];
|
String32(*SymtabF, name); // st_name
|
||||||
|
String32(*SymtabF, value); // st_value
|
||||||
String32(buf, name);
|
String32(*SymtabF, size); // st_size
|
||||||
SymtabF->getContents() += StringRef(buf, 4); // st_name
|
String8(*SymtabF, info); // st_info
|
||||||
|
String8(*SymtabF, other); // st_other
|
||||||
String32(buf, value);
|
String16(*SymtabF, Index); // st_shndx
|
||||||
SymtabF->getContents() += StringRef(buf, 4); // st_value
|
|
||||||
|
|
||||||
String32(buf, size);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 4); // st_size
|
|
||||||
|
|
||||||
String8(buf, info);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 1); // st_info
|
|
||||||
|
|
||||||
String8(buf, other);
|
|
||||||
SymtabF->getContents() += StringRef(buf, 1); // st_other
|
|
||||||
|
|
||||||
if (shndx >= ELF::SHN_LORESERVE && !Reserved)
|
|
||||||
String16(buf, ELF::SHN_XINDEX);
|
|
||||||
else
|
|
||||||
String16(buf, shndx);
|
|
||||||
|
|
||||||
SymtabF->getContents() += StringRef(buf, 2); // st_shndx
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,35 +1086,23 @@ void ELFObjectWriterImpl::WriteRelocationsFragment(const MCAssembler &Asm,
|
|||||||
else
|
else
|
||||||
entry.Index += LocalSymbolData.size() + 1;
|
entry.Index += LocalSymbolData.size() + 1;
|
||||||
if (Is64Bit) {
|
if (Is64Bit) {
|
||||||
char buf[8];
|
String64(*F, entry.r_offset);
|
||||||
|
|
||||||
String64(buf, entry.r_offset);
|
|
||||||
F->getContents() += StringRef(buf, 8);
|
|
||||||
|
|
||||||
struct ELF::Elf64_Rela ERE64;
|
struct ELF::Elf64_Rela ERE64;
|
||||||
ERE64.setSymbolAndType(entry.Index, entry.Type);
|
ERE64.setSymbolAndType(entry.Index, entry.Type);
|
||||||
String64(buf, ERE64.r_info);
|
String64(*F, ERE64.r_info);
|
||||||
F->getContents() += StringRef(buf, 8);
|
|
||||||
|
|
||||||
if (HasRelocationAddend) {
|
if (HasRelocationAddend)
|
||||||
String64(buf, entry.r_addend);
|
String64(*F, entry.r_addend);
|
||||||
F->getContents() += StringRef(buf, 8);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
char buf[4];
|
String32(*F, entry.r_offset);
|
||||||
|
|
||||||
String32(buf, entry.r_offset);
|
|
||||||
F->getContents() += StringRef(buf, 4);
|
|
||||||
|
|
||||||
struct ELF::Elf32_Rela ERE32;
|
struct ELF::Elf32_Rela ERE32;
|
||||||
ERE32.setSymbolAndType(entry.Index, entry.Type);
|
ERE32.setSymbolAndType(entry.Index, entry.Type);
|
||||||
String32(buf, ERE32.r_info);
|
String32(*F, ERE32.r_info);
|
||||||
F->getContents() += StringRef(buf, 4);
|
|
||||||
|
|
||||||
if (HasRelocationAddend) {
|
if (HasRelocationAddend)
|
||||||
String32(buf, entry.r_addend);
|
String32(*F, entry.r_addend);
|
||||||
F->getContents() += StringRef(buf, 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user