| 220 | } |
| 221 | |
| 222 | int main(int argc, char* argv[]) { |
| 223 | bool verbose = false; |
| 224 | bool rewrite_unique = false; |
| 225 | |
| 226 | using namespace NLastGetopt; |
| 227 | |
| 228 | TOpts opts = NLastGetopt::TOpts::Default(); |
| 229 | opts.AddHelpOption(); |
| 230 | |
| 231 | opts.AddLongOption('v', "verbose").NoArgument().StoreValue(&verbose, true); |
| 232 | opts.AddLongOption('u', "rewrite-gnu-unique", "Change STB_GNU_UNIQUE to STB_GLOBAL").NoArgument().StoreValue(&rewrite_unique, true); |
| 233 | |
| 234 | opts.SetFreeArgsMin(1); |
| 235 | opts.SetFreeArgTitle(0, "<file>", "File"); |
| 236 | |
| 237 | TOptsParseResult res(&opts, argc, argv); |
| 238 | TVector<TString> files = res.GetFreeArgs(); |
| 239 | |
| 240 | IOutputStream& verboseOut = verbose ? Cout : Cnull; |
| 241 | |
| 242 | bool first = true; |
| 243 | for (auto path : files) { |
| 244 | |
| 245 | if (!IsElf(path)) { |
| 246 | continue; |
| 247 | } |
| 248 | |
| 249 | if (!first) { |
| 250 | verboseOut << Endl; |
| 251 | } |
| 252 | first = false; |
| 253 | |
| 254 | verboseOut << "Patching " << path << Endl; |
| 255 | |
| 256 | try { |
| 257 | if (rewrite_unique) { |
| 258 | PatchGnuUnique(path, verboseOut); |
| 259 | } else { |
| 260 | Patch(path, "libc.so.6", verboseOut); |
| 261 | Patch(path, "libm.so.6", verboseOut); |
| 262 | } |
| 263 | } catch (const yexception& e) { |
| 264 | Cerr << "Patching failed: " << e.what() << Endl; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return 0; |
| 269 | } |
nothing calls this directly
no test coverage detected