[PATCH] D49870: [llvm-objcopy] Add support for --rename-section flags from gnu objcopy

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 27 17:31:29 PDT 2018


jakehehrlich added a comment.

LGTM, I had the same confusion James did. I have independently confirmed this is the correct behavior. As much as I dislike this behavior I think we need to match what GNU objcopy does here because this might result in observable differences in behavior (like a segfault if this is run on a ,o file and then linked)



================
Comment at: test/tools/llvm-objcopy/rename-section-flag.test:49
+# LOAD-NEXT: Flags [ (0x1)
+# LOAD-NEXT: SHF_WRITE (0x1)
+# LOAD-NEXT: ]
----------------
rupprecht wrote:
> jhenderson wrote:
> > I'm a bit surprised by this one. I haven't checked, but I'd expect load to cause SHF_ALLOC.
> That's what I thought as well. However,
> ```
> $ readelf -S /tmp/a.o | grep -A 1 .text
>   [ 2] .text             PROGBITS         0000000000000000  00000040
>        0000000000000000  0000000000000000  AX       0     0     4
> $ objcopy --rename-section=.text=.foo,load /tmp/a.o /tmp/a-gnu.o; readelf -S /tmp/a-gnu.o | grep -A 1 .foo
>   [ 1] .foo              PROGBITS         0000000000000000  00000040
>        0000000000000000  0000000000000000   W       0     0     4
> 
> ```
Ah ok, so if you add any flag at all *then* this is correct. if however you add no flag it does not change the flags. As much as I dislike this behavoir it's critical we match GNU objcopy here...sigh...


Repository:
  rL LLVM

https://reviews.llvm.org/D49870





More information about the llvm-commits mailing list