Skip to content
  1. Jan 11, 2019
  2. Jan 10, 2019
  3. Jan 08, 2019
  4. Jan 07, 2019
    • Jordan Rupprecht's avatar
      [llvm-objcopy] Handle -O <format> flag. · 70038e01
      Jordan Rupprecht authored
      Summary:
      The -O flag is currently being mostly ignored; it's only checked whether or not the output format is "binary". This adds support for a few formats (e.g. elf64-x86-64), so that when specified, the output can change between 32/64 bit and sizes/alignments are updated accordingly.
      
      This fixes PR39135
      
      Reviewers: jakehehrlich, jhenderson, alexshap, espindola
      
      Reviewed By: jhenderson
      
      Subscribers: emaste, arichardson, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D53667
      
      llvm-svn: 350541
      70038e01
  5. Jan 03, 2019
    • Jordan Rupprecht's avatar
      [llvm-objcopy][ELF] Implement a mutable section visitor that updates... · 1f82176f
      Jordan Rupprecht authored
      [llvm-objcopy][ELF] Implement a mutable section visitor that updates size-related fields (Size, EntrySize, Align) before layout.
      
      Summary:
      Fix EntrySize, Size, and Align before doing layout calculation.
      
      As a side cleanup, this removes a dependence on sizeof(Elf_Sym) within BinaryReader, so we can untemplatize that.
      
      This unblocks a cleaner implementation of handling the -O<format> flag. See D53667 for a previous attempt. Actual implementation of the -O<format> flag will come in an upcoming commit, this is largely a NFC (although not _totally_ one, because alignment on binary input was actually wrong before).
      
      Reviewers: jakehehrlich, jhenderson, alexshap, espindola
      
      Reviewed By: jhenderson
      
      Subscribers: emaste, arichardson, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D56211
      
      llvm-svn: 350336
      1f82176f
  6. Dec 20, 2018
  7. Dec 19, 2018
  8. Dec 06, 2018
    • Jake Ehrlich's avatar
      [llvm-objcopy] Change --only-keep to --only-section · 85985ed3
      Jake Ehrlich authored
      I just hard core goofed when I wrote this and created a different name
      for no good reason. I'm failry aware of most "fresh" users of llvm-objcopy
      (that is, users which are not using it as a drop in replacement for GNU
      objcopy) and can say that only "-j" is being used by such people so this
      patch should strictly increase compatibility and not remove it.
      
      Differential Revision: https://reviews.llvm.org/D52180
      
      llvm-svn: 348446
      85985ed3
  9. Dec 05, 2018
  10. Dec 03, 2018
    • Jake Ehrlich's avatar
      [llvm-objcopy] Add --build-id-link-dir flag · 8ad77790
      Jake Ehrlich authored
      This flag does not exist in GNU objcopy but has a major use case.
      Debugging tools support the .build-id directory structure to find
      debug binaries. There is no easy way to build this structure up
      however. One way to do it is by using llvm-readelf and some crazy
      shell magic. This implements the feature directly. It is most often
      the case that you'll want to strip a file and send the original to
      the .build-id directory but if you just want to send a file to the
      .build-id directory you can copy to /dev/null instead.
      
      Differential Revision: https://reviews.llvm.org/D54384
      
      llvm-svn: 348174
      8ad77790
  11. Nov 30, 2018
  12. Nov 28, 2018
  13. Nov 13, 2018
    • Jordan Rupprecht's avatar
      [llvm-objcopy] Rename --keep to --keep-section. · c5bae783
      Jordan Rupprecht authored
      Summary:
      llvm-objcopy/strip support `--keep` (for sections) and `--keep-symbols` (for symbols). For consistency and clarity, rename `--keep` to `--keep-section`.
      In fact, for GNU compatability, -K is --keep-symbol, so it's weird that the alias `-K` is not the same as the short-ish `--keep`.
      
      Reviewers: jakehehrlich, jhenderson, alexshap, MaskRay, espindola
      
      Reviewed By: jakehehrlich, MaskRay
      
      Subscribers: emaste, arichardson, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D54477
      
      llvm-svn: 346782
      c5bae783
  14. Nov 01, 2018
  15. Oct 30, 2018
  16. Oct 23, 2018
    • Jordan Rupprecht's avatar
      [llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy... · aaeaa0a8
      Jordan Rupprecht authored
      [llvm-strip] Support -s alias for --strip-all. Make both strip and objcopy case sensitive to support both -s (--strip-all) and -S (--strip-debug).
      
      Summary:
      GNU strip supports both `-s` and `-S` as aliases for `--strip-all` and `--strip-debug`, respectfully.
      
      As part of this, it turns out that strip/objcopy were accepting case insensitive command line args. I'm not sure if there was an explicit reason for this. The only others uses of this are llvm-cvtres/llvm-mt/llvm-lib, which are all tools specific for windows support. Forcing case sensitivity allows both aliases to exist, but seems like a good idea anyway.
      
      And as a surprise test case adjustment, the llvm-strip unit test was running with `-keep=unavailable_symbol`, despite `keep` not be a valid flag for strip. This is because there is a flag `-K` which, when case insensitivity is permitted, allows it to be interpreted as `-K` = `eep=unavailable_symbol` (e.g. to allow `-Kfoo` == `--keep-symbol=foo`).
      
      Reviewers: jakehehrlich, jhenderson, alexshap
      
      Reviewed By: jakehehrlich
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D53163
      
      llvm-svn: 345068
      aaeaa0a8
  17. Oct 15, 2018
  18. Oct 12, 2018
    • Jordan Rupprecht's avatar
      [llvm-objcopy] Add -F|--target compatibility · bb4588e9
      Jordan Rupprecht authored
      Summary:
      This change adds support for the GNU --target flag, which sets both --input-target and --output-target.
      
      GNU objcopy doesn't do any checking for whether both --target and --{input,output}-target are used, and so it allows both, e.g. "--target A --output-target B" is equivalent to "--input-target A --output-target B" since the later command line flag would override earlier ones. This may be error prone, so I chose to implement it as an error if both are used. I'm not sure if anyone is actually using both.
      
      Reviewers: jakehehrlich, jhenderson, alexshap
      
      Reviewed By: jakehehrlich, alexshap
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D53029
      
      llvm-svn: 344321
      bb4588e9
  19. Oct 09, 2018
  20. Oct 01, 2018
  21. Sep 21, 2018
    • Jordan Rupprecht's avatar
      [llvm-objcopy/llvm-strip]: handle --version · 7b1c8168
      Jordan Rupprecht authored
      Summary:
      Implement --version for objcopy and strip.
      
      I think there are LLVM utilities that automatically handle this, but that doesn't seem to work with custom parsing since this binary handles both objcopy and strip, so it uses custom parsing.
      
      This fixes PR38298
      
      Reviewers: jhenderson, alexshap, jakehehrlich
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D52328
      
      llvm-svn: 342702
      7b1c8168
  22. Sep 17, 2018
  23. Sep 12, 2018
    • Julie Hockett's avatar
      [objcopy] make objcopy follow program header standards · 468722ee
      Julie Hockett authored
      Submitted on behalf of Armando Montanez (amontanez@google.com).
      
      Objects with unused program headers copied by objcopy would always have
      nonzero values for program header offset and program header entry size.
      While technically valid, this atypical behavior triggers warnings in some
      tools. This change sets the two fields to zero when the program header is
      unused, better fitting the general expectations for unused program header
      data.
      
      Section headers behaved somewhat similarly (though only with the entry size),
      and are fixed in this revision as well.
      
      Differential Revision: https://reviews.llvm.org/D51961
      
      llvm-svn: 342065
      468722ee
  24. Sep 07, 2018
  25. Sep 05, 2018
    • Jordan Rupprecht's avatar
      [llvm-strip] Support stripping multiple input files · 591d8890
      Jordan Rupprecht authored
      Summary:
      Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o.
      
      To allow this, create a `DriverConfig` struct which just wraps a list of `CopyConfigs`. objcopy will only ever have a single `CopyConfig`, but strip will have N (where N >= 1) CopyConfigs.
      
      Reviewers: alexshap, jakehehrlich
      
      Reviewed By: alexshap, jakehehrlich
      
      Subscribers: MaskRay, jakehehrlich, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D51660
      
      llvm-svn: 341464
      591d8890
    • Jordan Rupprecht's avatar
      [llvm-strip] Allow copying relocation sections without symbol tables. · ec277a82
      Jordan Rupprecht authored
      Summary:
      Fixes the error "Link field value 0 in section .rela.plt is invalid" when copying/stripping certain binaries. Minimal repro:
      
      ```
      $ cat /tmp/a.c
      int main() { return 0; }
      $ clang -static /tmp/a.c -o /tmp/a
      $ llvm-strip /tmp/a -o /tmp/b
      llvm-strip: error: Link field value 0 in section .rela.plt is invalid.
      ```
      
      Reviewers: jakehehrlich, alexshap
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D51493
      
      llvm-svn: 341419
      ec277a82
  26. Sep 04, 2018
  27. Aug 30, 2018
    • Jordan Rupprecht's avatar
      [llvm-strip] Fix -p|--preserve-dates to not truncate output when used in-place. · 7481540f
      Jordan Rupprecht authored
      The restoreDateOnFile() method used to preserve dates uses sys::fs::openFileForWrite(). That method defaults to opening files with CD_CreateAlways, which truncates the output file if it exists. Use CD_OpenExisting instead to open it and *not* truncate it, which also has the side benefit of erroring if the file does not exist (it should always exist, because we just wrote it out).
      
      Also, fix the test case to make sure the output is a valid output file, and not empty. The extra test assertions are enough to catch this regression.
      
      llvm-svn: 340996
      7481540f
  28. Aug 18, 2018
    • Jordan Rupprecht's avatar
      [llvm-objcopy] Implement -G/--keep-global-symbol(s). · be8ebcca
      Jordan Rupprecht authored
      Summary:
      Port GNU Objcopy -G/--keep-global-symbol(s).
      
      This is slightly different than the already-implemented --globalize-symbol, which marks a symbol as global when copying. When --keep-global-symbol (alias -G) is used, *only* those symbols marked will stay global, and all other globals are demoted to local. (Also note that it doesn't *promote* a symbol to global). Additionally, there is a pluralized version of the flag --keep-global-symbols, which effectively applies --keep-global-symbol for every non-comment in a file.
      
      Reviewers: jakehehrlich, jhenderson, alexshap
      
      Reviewed By: jhenderson
      
      Subscribers: llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D50589
      
      llvm-svn: 340105
      be8ebcca
  29. Aug 17, 2018
    • Jordan Rupprecht's avatar
      Fix windows buildbots by removing : from filenames · bb179a19
      Jordan Rupprecht authored
      llvm-svn: 340071
      bb179a19
    • Jordan Rupprecht's avatar
      [llvm-objcopy] Add support for -I binary -B <arch>. · cf67633e
      Jordan Rupprecht authored
      Summary:
      The -I (--input-target) and -B (--binary-architecture) flags exist but are currently silently ignored. This adds support for -I binary for architectures i386, x86-64 (and alias i386:x86-64), arm, aarch64, sparc, and ppc (powerpc:common64). This is largely based on D41687.
      
      This is done by implementing an additional subclass of Reader, BinaryReader, which works by interpreting the input file as contents for .data field, sets up a synthetic header, and adds additional sections/symbols (e.g. _binary__tmp_data_txt_start).
      
      Reviewers: jakehehrlich, alexshap, jhenderson, javed.absar
      
      Reviewed By: jhenderson
      
      Subscribers: jyknight, nemanjai, kbarton, fedor.sergeev, jrtc27, kristof.beyls, paulsemel, llvm-commits
      
      Differential Revision: https://reviews.llvm.org/D50343
      
      llvm-svn: 340070
      cf67633e
Loading