Lines Matching defs:LC

33 using LoadCommandPred = std::function<bool(const LoadCommand &LC)>;
36 static bool isLoadCommandWithPayloadString(const LoadCommand &LC) {
39 return LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH ||
40 LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_ID_DYLIB ||
41 LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_LOAD_DYLIB ||
42 LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_LOAD_WEAK_DYLIB;
46 static StringRef getPayloadString(const LoadCommand &LC) {
47 assert(isLoadCommandWithPayloadString(LC) &&
50 return StringRef(reinterpret_cast<const char *>(LC.Payload.data()),
51 LC.Payload.size())
156 static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
157 assert(isLoadCommandWithPayloadString(LC) &&
162 LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
163 LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
164 std::copy(S.begin(), S.end(), LC.Payload.begin());
168 LoadCommand LC;
173 LC.MachOLoadCommand.rpath_command_data = RPathLC;
174 LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
175 std::copy(Path.begin(), Path.end(), LC.Payload.begin());
176 return LC;
185 &MachOConfig](const LoadCommand &LC) {
186 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH) {
192 StringRef RPath = getPayloadString(LC);
216 for (LoadCommand &LC : Obj.LoadCommands) {
217 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH)
218 RPaths.insert(getPayloadString(LC));
235 for (LoadCommand &LC : Obj.LoadCommands) {
236 switch (LC.MachOLoadCommand.load_command_data.cmd) {
240 LC, *MachOConfig.SharedLibId);
244 StringRef RPath = getPayloadString(LC);
247 updateLoadCommandPayloadString<MachO::rpath_command>(LC, NewRPath);
255 StringRef InstallName = getPayloadString(LC);
259 updateLoadCommandPayloadString<MachO::dylib_command>(LC,
293 auto RemovePred = [&MachOConfig](const LoadCommand &LC) {
294 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_SEGMENT_64 ||
295 LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_SEGMENT) {
296 return LC.Sections.empty() &&
297 MachOConfig.EmptySegmentsToRemove.contains(*LC.getSegmentName());
310 for (LoadCommand &LC : Obj.LoadCommands)
311 for (const std::unique_ptr<Section> &Sec : LC.Sections) {
339 for (LoadCommand &LC : Obj.LoadCommands) {
340 std::optional<StringRef> SegName = LC.getSegmentName();
342 uint64_t Addr = *LC.getSegmentVMAddr();
343 for (const std::unique_ptr<Section> &S : LC.Sections)
345 LC.Sections.push_back(std::make_unique<Section>(Sec));
346 LC.Sections.back()->Addr = Addr;
364 llvm::find_if(O.LoadCommands, [SegName](const LoadCommand &LC) {
365 return LC.getSegmentName() == SegName;
443 for (LoadCommand &LC : Obj.LoadCommands)
444 for (std::unique_ptr<Section> &Sec : LC.Sections)