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())
137 static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
138 assert(isLoadCommandWithPayloadString(LC) &&
143 LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
144 LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
145 std::copy(S.begin(), S.end(), LC.Payload.begin());
149 LoadCommand LC;
154 LC.MachOLoadCommand.rpath_command_data = RPathLC;
155 LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
156 std::copy(Path.begin(), Path.end(), LC.Payload.begin());
157 return LC;
166 &MachOConfig](const LoadCommand &LC) {
167 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH) {
173 StringRef RPath = getPayloadString(LC);
197 for (LoadCommand &LC : Obj.LoadCommands) {
198 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_RPATH)
199 RPaths.insert(getPayloadString(LC));
216 for (LoadCommand &LC : Obj.LoadCommands) {
217 switch (LC.MachOLoadCommand.load_command_data.cmd) {
221 LC, *MachOConfig.SharedLibId);
225 StringRef RPath = getPayloadString(LC);
228 updateLoadCommandPayloadString<MachO::rpath_command>(LC, NewRPath);
236 StringRef InstallName = getPayloadString(LC);
240 updateLoadCommandPayloadString<MachO::dylib_command>(LC,
274 auto RemovePred = [&MachOConfig](const LoadCommand &LC) {
275 if (LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_SEGMENT_64 ||
276 LC.MachOLoadCommand.load_command_data.cmd == MachO::LC_SEGMENT) {
277 return LC.Sections.empty() &&
278 MachOConfig.EmptySegmentsToRemove.contains(*LC.getSegmentName());
291 for (LoadCommand &LC : Obj.LoadCommands)
292 for (const std::unique_ptr<Section> &Sec : LC.Sections) {
320 for (LoadCommand &LC : Obj.LoadCommands) {
321 std::optional<StringRef> SegName = LC.getSegmentName();
323 uint64_t Addr = *LC.getSegmentVMAddr();
324 for (const std::unique_ptr<Section> &S : LC.Sections)
326 LC.Sections.push_back(std::make_unique<Section>(Sec));
327 LC.Sections.back()->Addr = Addr;
345 llvm::find_if(O.LoadCommands, [SegName](const LoadCommand &LC) {
346 return LC.getSegmentName() == SegName;
424 for (LoadCommand &LC : Obj.LoadCommands)
425 for (std::unique_ptr<Section> &Sec : LC.Sections)