forked from OSchip/llvm-project
[ObjCopy][NFC] Refactor handling of linkedit_data_command
This commit is contained in:
parent
bdbfaf0ca7
commit
ddc0908949
|
@ -94,64 +94,18 @@ size_t MachOWriter::totalSize() const {
|
|||
sizeof(uint32_t) * O.IndirectSymTable.Symbols.size());
|
||||
}
|
||||
|
||||
if (O.CodeSignatureCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.CodeSignatureCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
if (O.DataInCodeCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.DataInCodeCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
if (O.LinkerOptimizationHintCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.LinkerOptimizationHintCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
if (O.FunctionStartsCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.FunctionStartsCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
if (O.ChainedFixupsCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.ChainedFixupsCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
if (O.ExportsTrieCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*O.ExportsTrieCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
for (Optional<size_t> LinkEditDataCommandIndex :
|
||||
{O.CodeSignatureCommandIndex, O.DataInCodeCommandIndex,
|
||||
O.LinkerOptimizationHintCommandIndex, O.FunctionStartsCommandIndex,
|
||||
O.ChainedFixupsCommandIndex, O.ExportsTrieCommandIndex})
|
||||
if (LinkEditDataCommandIndex) {
|
||||
const MachO::linkedit_data_command &LinkEditDataCommand =
|
||||
O.LoadCommands[*LinkEditDataCommandIndex]
|
||||
.MachOLoadCommand.linkedit_data_command_data;
|
||||
if (LinkEditDataCommand.dataoff)
|
||||
Ends.push_back(LinkEditDataCommand.dataoff +
|
||||
LinkEditDataCommand.datasize);
|
||||
}
|
||||
|
||||
// Otherwise, use the last section / reloction.
|
||||
for (const LoadCommand &LC : O.LoadCommands)
|
||||
|
|
Loading…
Reference in New Issue