Skip to content

Commit d40b0eb

Browse files
committed
llvm-objcopy MachO: scan each section when --update-section option is used
1 parent f00b32e commit d40b0eb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ static Error addSection(const NewSectionInfo &NewSection, Object &Obj) {
360360
static Expected<Section &> findSection(StringRef SecName, Object &O) {
361361
StringRef SegName;
362362
std::tie(SegName, SecName) = SecName.split(",");
363+
if (O.Header.FileType == MachO::HeaderFileType::MH_OBJECT) {
364+
for (const auto& LC : O.LoadCommands)
365+
for (const auto& Sec : LC.Sections)
366+
if (Sec->Segname == SegName && Sec->Sectname == SecName)
367+
return *Sec;
368+
}
363369
auto FoundSeg =
364370
llvm::find_if(O.LoadCommands, [SegName](const LoadCommand &LC) {
365371
return LC.getSegmentName() == SegName;

0 commit comments

Comments
 (0)