mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-09 01:38:03 +00:00
Extract printBSDMemberHeader.
It will get another use in the following patch. Also rename the other helper to printGNUSmallMemberHeader for consistency. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b13f72aa2d
commit
56240eaf73
@ -107,37 +107,40 @@ static void printRestOfMemberHeader(raw_fd_ostream &Out,
|
||||
Out << "`\n";
|
||||
}
|
||||
|
||||
static void printMemberHeader(raw_fd_ostream &Out, StringRef Name,
|
||||
const sys::TimeValue &ModTime, unsigned UID,
|
||||
unsigned GID, unsigned Perms, unsigned Size) {
|
||||
static void printGNUSmallMemberHeader(raw_fd_ostream &Out, StringRef Name,
|
||||
const sys::TimeValue &ModTime,
|
||||
unsigned UID, unsigned GID,
|
||||
unsigned Perms, unsigned Size) {
|
||||
printWithSpacePadding(Out, Twine(Name) + "/", 16);
|
||||
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
|
||||
}
|
||||
|
||||
static void printBSDMemberHeader(raw_fd_ostream &Out, StringRef Name,
|
||||
const sys::TimeValue &ModTime, unsigned UID,
|
||||
unsigned GID, unsigned Perms, unsigned Size) {
|
||||
uint64_t PosAfterHeader = Out.tell() + 60 + Name.size();
|
||||
// Pad so that even 64 bit object files are aligned.
|
||||
unsigned Pad = OffsetToAlignment(PosAfterHeader, 8);
|
||||
unsigned NameWithPadding = Name.size() + Pad;
|
||||
printWithSpacePadding(Out, Twine("#1/") + Twine(NameWithPadding), 16);
|
||||
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms,
|
||||
NameWithPadding + Size);
|
||||
Out << Name;
|
||||
assert(PosAfterHeader == Out.tell());
|
||||
while (Pad--)
|
||||
Out.write(uint8_t(0));
|
||||
}
|
||||
|
||||
static void
|
||||
printMemberHeader(raw_fd_ostream &Out, object::Archive::Kind Kind,
|
||||
StringRef Name,
|
||||
std::vector<unsigned>::iterator &StringMapIndexIter,
|
||||
const sys::TimeValue &ModTime, unsigned UID, unsigned GID,
|
||||
unsigned Perms, unsigned Size) {
|
||||
if (Kind == object::Archive::K_BSD) {
|
||||
uint64_t PosAfterHeader = Out.tell() + 60 + Name.size();
|
||||
// Pad so that even 64 bit object files are aligned.
|
||||
unsigned Pad = OffsetToAlignment(PosAfterHeader, 8);
|
||||
unsigned NameWithPadding = Name.size() + Pad;
|
||||
printWithSpacePadding(Out, Twine("#1/") + Twine(NameWithPadding), 16);
|
||||
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms,
|
||||
NameWithPadding + Size);
|
||||
Out << Name;
|
||||
assert(PosAfterHeader == Out.tell());
|
||||
while (Pad--)
|
||||
Out.write(uint8_t(0));
|
||||
return;
|
||||
}
|
||||
if (Name.size() < 16) {
|
||||
printMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
|
||||
return;
|
||||
}
|
||||
if (Kind == object::Archive::K_BSD)
|
||||
return printBSDMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
|
||||
if (Name.size() < 16)
|
||||
return printGNUSmallMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
|
||||
Out << '/';
|
||||
printWithSpacePadding(Out, *StringMapIndexIter++, 15);
|
||||
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
|
||||
@ -195,7 +198,7 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind,
|
||||
object::SymbolicFile &Obj = *ObjOrErr.get();
|
||||
|
||||
if (!StartOffset) {
|
||||
printMemberHeader(Out, "", sys::TimeValue::now(), 0, 0, 0, 0);
|
||||
printGNUSmallMemberHeader(Out, "", sys::TimeValue::now(), 0, 0, 0, 0);
|
||||
StartOffset = Out.tell();
|
||||
print32BE(Out, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user