[llvm-dev] Proposal for Mach-O support in llvm-objcopy: section renaming
James Henderson via llvm-dev
llvm-dev at lists.llvm.org
Thu May 23 02:05:46 PDT 2019
I discussed this with Seiya off the mailing list yesterday, and this was
the suggestion we came up with, on the basis that GNU objcopy has support
for the renaming for GDB support, but it might be confusing to people who
are new to the system, so we provide a more expected output option. I'm not
experienced with MachO at all, though, so we'd appreciate any feedback from
any MachO users.
Thanks,
James
On Thu, 23 May 2019 at 05:43, Seiya Nuta <nuta at seiya.me> wrote:
> Hi,
>
> I'm going to implement Mach-O support in llvm-objcopy. Before working
> on this, I'd like to hear your thoughts how llvm-objcopy should handle
> Mach-O section names.
>
> By convention, Mach-O section names are denoted by "<segment
> name>,<section name>". However, GNU objcopy renames them in the
> following rule [1]:
>
> - If the section name is well-known, rename it to an "canonical" name [2].
> - Otherwise:
> - Rename to "<segment name>.<section name>" (the separator is `.' not
> `,')
> - If the segment name does not start with `_', prefix it with
> `LC_SEGMENT.'
>
> For example, __TEXT,__text is renamed to .text and
> __TEXT,__unwind_info is renamed to __TEXT.__unwind_info. For that
> reason, specifying a section in command line options is rather
> nonintuitive:
>
> WRONG: objcopy --only-secton=__TEXT,__text a.out
> WRONG: objcopy --only-secton=__TEXT.__text a.out
> OK: objcopy --only-secton=.text a.out
>
> WRONG: objcopy --only-secton=__TEXT,__unwind_info a.out
> WRONG: objcopy --only-secton=.unwind_info a.out
> OK: objcopy --only-secton=__TEXT.__unwind_info a.out
>
> For the compatibility with GNU binutils, I propose to make this
> section renaming rule as default in llvm-objcopy and implement a flag
> named —macho-names to use conventional section names:
>
> WRONG: llvm-objcopy --only-secton=__TEXT,__text a.out
> WRONG: llvm-objcopy --only-secton=__TEXT.__text a.out
> OK: llvm-objcopy --only-secton=.text a.out a.out2
>
> WRONG: llvm-objcopy --macho-names --only-secton=.text a.out
> WRONG: llvm-objcopy --macho-names --only-secton=__TEXT.__text a.out
> OK: llvm-objcopy --macho-names --only-secton=__TEXT,__text a.out
>
> What do you think about this behavior?
>
> Thanks,
> Seiya
>
> [1]:
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/mach-o.c;h=d9edef2871d83b53280b613935c068e4327f3270;hb=HEAD#l364
> [2]:
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=bfd/mach-o.c;h=d9edef2871d83b53280b613935c068e4327f3270;hb=HEAD#l90
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190523/6a5fc83a/attachment-0001.html>
More information about the llvm-dev
mailing list