Add code to llvm-objdump so the -section option with -macho will dump literal pointer sections
with the Mach-O S_LITERAL_POINTERS section type.

Also fix the printing of the leading addresses for literal sections to be consistent and
not print the 0x prefix.  Updated test cases to match.

llvm-svn: 229548
diff --git a/llvm/test/tools/llvm-objdump/X86/macho-cstring-dump.test b/llvm/test/tools/llvm-objdump/X86/macho-cstring-dump.test
index 869462d..3dfa4e3 100644
--- a/llvm/test/tools/llvm-objdump/X86/macho-cstring-dump.test
+++ b/llvm/test/tools/llvm-objdump/X86/macho-cstring-dump.test
@@ -1,4 +1,4 @@
 RUN: llvm-objdump -m -section __TEXT,__cstring %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
 
 CHECK: Contents of (__TEXT,__cstring) section
-CHECK: 0x000000000000003b  Hello world\n
+CHECK: 000000000000003b  Hello world\n
diff --git a/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-i386.test b/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-i386.test
new file mode 100644
index 0000000..0069668
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-i386.test
@@ -0,0 +1,34 @@
+# RUN: llvm-mc < %s -triple i386-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp - | FileCheck %s
+
+.cstring
+L1: .asciz "Hello world\n"
+
+.literal4
+.align 2
+L2: .float 4.0
+
+.literal8
+.align 3
+L3: .double 8.0
+
+.literal16
+.align 4
+L4: .long 0x10000016, 0x20000016, 0x30000016, 0x40000016
+
+.const
+L5: .asciz "const non-literal string"
+
+.section __DATA,__litp, literal_pointers
+.align 2
+.long L1
+.long L2
+.long L3
+.long L4
+.long L5
+
+# CHECK: Contents of (__DATA,__litp) section
+# CHECK: 0000004c  __TEXT:__cstring:Hello world\n
+# CHECK: 00000050  __TEXT:__literal4:0x40800000
+# CHECK: 00000054  __TEXT:__literal8:0x00000000 0x40200000
+# CHECK: 00000058  __TEXT:__literal16:0x10000016 0x20000016 0x30000016 0x40000016
+# CHECK: 0000005c  0x30 (not in a literal section)
diff --git a/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-x86_64.test b/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-x86_64.test
new file mode 100644
index 0000000..b403b81
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/X86/macho-literal-pointers-x86_64.test
@@ -0,0 +1,34 @@
+# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -section __DATA,__litp - | FileCheck %s
+
+.cstring
+L1: .asciz "Hello world\n"
+
+.literal4
+.align 2
+L2: .float 4.0
+
+.literal8
+.align 3
+L3: .double 8.0
+
+.literal16
+.align 4
+L4: .long 0x10000016, 0x20000016, 0x30000016, 0x40000016
+
+.const
+L5: .asciz "const non-literal string"
+
+.section __DATA,__litp, literal_pointers
+.align 3
+.quad L1
+.quad L2
+.quad L3
+.quad L4
+.quad L5
+
+# CHECK: Contents of (__DATA,__litp) section
+# CHECK: 0000000000000050  __TEXT:__cstring:Hello world\n
+# CHECK: 0000000000000058  __TEXT:__literal4:0x40800000
+# CHECK: 0000000000000060  __TEXT:__literal8:0x00000000 0x40200000
+# CHECK: 0000000000000068  __TEXT:__literal16:0x10000016 0x20000016 0x30000016 0x40000016
+# CHECK: 0000000000000070  0x30 (not in a literal section)
diff --git a/llvm/test/tools/llvm-objdump/X86/macho-literals.test b/llvm/test/tools/llvm-objdump/X86/macho-literals.test
index 2acac7d..4824453 100644
--- a/llvm/test/tools/llvm-objdump/X86/macho-literals.test
+++ b/llvm/test/tools/llvm-objdump/X86/macho-literals.test
@@ -11,12 +11,12 @@
 .long 0x7f800001
 
 # CHECK-LIT4: Contents of (__TEXT,__literal4) section
-# CHECK-LIT4: 0x0000000000000000  0x40200000
-# CHECK-LIT4: 0x0000000000000004  0x41040000
-# CHECK-LIT4: 0x0000000000000008  0x7f800000
-# CHECK-LIT4: 0x000000000000000c  0xff800000
-# CHECK-LIT4: 0x0000000000000010  0x7fc00000
-# CHECK-LIT4: 0x0000000000000014  0x7f800001
+# CHECK-LIT4: 0000000000000000  0x40200000
+# CHECK-LIT4: 0000000000000004  0x41040000
+# CHECK-LIT4: 0000000000000008  0x7f800000
+# CHECK-LIT4: 000000000000000c  0xff800000
+# CHECK-LIT4: 0000000000000010  0x7fc00000
+# CHECK-LIT4: 0000000000000014  0x7f800001
 
 .literal8
 .double 2.5
@@ -31,12 +31,12 @@
 .long 0x7ff00000
 
 # CHECK-LIT8: Contents of (__TEXT,__literal8) section
-# CHECK-LIT8: 0x0000000000000018  0x00000000 0x40040000
-# CHECK-LIT8: 0x0000000000000020  0x00000000 0x40208000
-# CHECK-LIT8: 0x0000000000000028  0x00000000 0x7ff00000
-# CHECK-LIT8: 0x0000000000000030  0x00000000 0xfff00000
-# CHECK-LIT8: 0x0000000000000038  0x00000000 0x7ff80000
-# CHECK-LIT8: 0x0000000000000040  0x00000001 0x7ff00000
+# CHECK-LIT8: 0000000000000018  0x00000000 0x40040000
+# CHECK-LIT8: 0000000000000020  0x00000000 0x40208000
+# CHECK-LIT8: 0000000000000028  0x00000000 0x7ff00000
+# CHECK-LIT8: 0000000000000030  0x00000000 0xfff00000
+# CHECK-LIT8: 0000000000000038  0x00000000 0x7ff80000
+# CHECK-LIT8: 0000000000000040  0x00000001 0x7ff00000
 
 .literal16
 .long 1
@@ -45,4 +45,4 @@
 .long 4
 
 # CHECK-LIT16: Contents of (__TEXT,__literal16) section
-# CHECK-LIT16: 0x0000000000000050  0x00000001 0x00000002 0x00000003 0x00000004
+# CHECK-LIT16: 0000000000000050  0x00000001 0x00000002 0x00000003 0x00000004