[llvm-bugs] [Bug 27049] New: llvm-nm -P violates POSIX specification

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 24 01:19:14 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27049

            Bug ID: 27049
           Summary: llvm-nm -P violates POSIX specification
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-nm
          Assignee: unassignedbugs at nondot.org
          Reporter: hvr at gnu.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

On Linux/amd64 with a recent llvm-nm snapshot (same with llvm-nm-3.8):

$ echo 'char foo[200];' >> foo.c
$ cc -c foo.c
$ llvm-nm-3.9 -P foo.o 
foo C 00000000000000c80000000000000000

whearas GNU binutils' `nm` says:
$ nm -P foo.o
foo C 00000000000000c8 00000000000000c8


So `llvm-nm` violates the portable format mandated by POSIX
(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nm.html) by leaving
out the space,
which specifically states:

> `-P`
>    Write information in a portable output format, as specified in the STDOUT section.

...

> If the `-P` option is specified, the previous information shall be displayed using the following portable format. The three versions differ depending on whether `-t d`, `-t o`, or `-t x` was specified, respectively:
>
> "%s%s %s %d %d\n", <library/object name>, <name>, <type>, <value>, <size>
>
> "%s%s %s %o %o\n", <library/object name>, <name>, <type>, <value>, <size>
>
> "%s%s %s %x %x\n", <library/object name>, <name>, <type>, <value>, <size>

...

> If `-P` is specified, but `-t` is not, the format shall be as if `-t x` had been specified.

...

> The format given in nm STDOUT uses <space> characters between the fields, which may be any number of <blank> characters required to align the columns. The single-character types were selected to match historical practice, and the requirement that implementation additions also be single characters made parsing the information easier for shell scripts.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160324/099ee308/attachment.html>


More information about the llvm-bugs mailing list