aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2012-01-03 10:54:01 +0000
committerIain Sandoe <iain@codesourcery.com>2012-01-03 10:54:01 +0000
commit7f3072381b852817638295d676689b211af03c50 (patch)
tree7e0b9316807305c1a6851fffa3d564e0576ab597 /gas
parent3c2d6aff67c0d33ed51d588bd7780f2fc0cfad1b (diff)
downloadgdb-7f3072381b852817638295d676689b211af03c50.zip
gdb-7f3072381b852817638295d676689b211af03c50.tar.gz
gdb-7f3072381b852817638295d676689b211af03c50.tar.bz2
add dysymtab write support to bfd/mach-o.
bfd: * mach-o.c (bfd_mach_o_write_symtab): Fill in the string table index as the value of an indirect symbol. Keep the string table index in non-indirect syms for reference. (bfd_mach_o_write_dysymtab): New. (bfd_mach_o_primary_symbol_sort_key): New. (bfd_mach_o_cf_symbols): New. (bfd_mach_o_sort_symbol_table): New. (bfd_mach_o_mangle_symbols): Return early if no symbols. Sort symbols. If we are emitting a dysymtab, process indirect symbols and count the number of each other kind. (bfd_mach_o_mangle_sections): New. (bfd_mach_o_write_contents): Split out some pre-requisite code into the command builder. Write dysymtab if the command is present. (bfd_mach_o_count_sections_for_seg): New. (bfd_mach_o_build_seg_command): New. (bfd_mach_o_build_dysymtab_command): New. (bfd_mach_o_build_commands): Reorganize to support the fact that some commands are optional and should not be emitted if there are no sections or symbols. (bfd_mach_o_set_section_contents): Amend comment. * mach-o.h: Amend and add to comments. (mach_o_data_struct): Add fields for dysymtab symbols counts and a pointer to the indirects, when present. (bfd_mach_o_should_emit_dysymtab): New macro. (IS_MACHO_INDIRECT): Likewise. gas/testsuite: * gas/mach-o/dysymtab-1-64.d: New. * gas/mach-o/dysymtab-1.d: New. * gas/mach-o/symbols-1-64.d: New. * gas/mach-o/symbols-1.d: New. * gas/mach-o/symbols-base-64.s: New. * gas/mach-o/symbols-base.s: New.
Diffstat (limited to 'gas')
-rw-r--r--gas/testsuite/ChangeLog9
-rw-r--r--gas/testsuite/gas/mach-o/dysymtab-1-64.d15
-rw-r--r--gas/testsuite/gas/mach-o/dysymtab-1.d15
-rw-r--r--gas/testsuite/gas/mach-o/symbols-1-64.d70
-rw-r--r--gas/testsuite/gas/mach-o/symbols-1.d70
-rw-r--r--gas/testsuite/gas/mach-o/symbols-base-64.s97
-rw-r--r--gas/testsuite/gas/mach-o/symbols-base.s97
7 files changed, 373 insertions, 0 deletions
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 80f9a73..624ee9f 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2012-01-03 Iain Sandoe <idsandoe@googlemail.com>
+
+ * gas/mach-o/dysymtab-1-64.d: New.
+ * gas/mach-o/dysymtab-1.d: New.
+ * gas/mach-o/symbols-1-64.d: New.
+ * gas/mach-o/symbols-1.d: New.
+ * gas/mach-o/symbols-base-64.s: New.
+ * gas/mach-o/symbols-base.s: New.
+
2011-12-29 Iain Sandoe <idsandoe@googlemail.com>
* gas/mach-o/sections-1.d: Amend to recognize that bss is not emitted
diff --git a/gas/testsuite/gas/mach-o/dysymtab-1-64.d b/gas/testsuite/gas/mach-o/dysymtab-1-64.d
new file mode 100644
index 0000000..2b2b419
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/dysymtab-1-64.d
@@ -0,0 +1,15 @@
+#objdump: -P dysymtab
+#target: x86_64-*-darwin* powerpc64-*-darwin*
+#source: symbols-base-64.s
+.*: +file format mach-o.*
+#...
+Load command dysymtab:
+ local symbols: idx: 0 num: 6.*\(nxtidx: 6\)
+ external symbols: idx: 6 num: 18.*\(nxtidx: 24\)
+ undefined symbols: idx: 24 num: 21.*\(nxtidx: 45\)
+ table of content: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ module table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ external reference table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ indirect symbol table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ external relocation table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ local relocation table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
diff --git a/gas/testsuite/gas/mach-o/dysymtab-1.d b/gas/testsuite/gas/mach-o/dysymtab-1.d
new file mode 100644
index 0000000..48db498
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/dysymtab-1.d
@@ -0,0 +1,15 @@
+#objdump: -P dysymtab
+#target: i?86-*-darwin* powerpc-*-darwin*
+#source: symbols-base.s
+.*: +file format mach-o.*
+#...
+Load command dysymtab:
+ local symbols: idx: 0 num: 6.*\(nxtidx: 6\)
+ external symbols: idx: 6 num: 18.*\(nxtidx: 24\)
+ undefined symbols: idx: 24 num: 21.*\(nxtidx: 45\)
+ table of content: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ module table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ external reference table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ indirect symbol table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ external relocation table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
+ local relocation table: off: 0x00000000 num: 0.*\(endoff: 0x00000000\)
diff --git a/gas/testsuite/gas/mach-o/symbols-1-64.d b/gas/testsuite/gas/mach-o/symbols-1-64.d
new file mode 100644
index 0000000..9d23ee1
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/symbols-1-64.d
@@ -0,0 +1,70 @@
+#as: -L
+#objdump: -t
+#target: x86_64-*-darwin* powerpc64-*-darwin*
+#source: symbols-base-64.s
+.*: +file format mach-o.*
+#...
+SYMBOL TABLE:
+0000000000000000 l.*0e SECT 01 0000 \[.text\] Lzt0
+0000000000000002 l.*0e SECT 01 0000 \[.text\] Lmt0
+0000000000000004 l.*0e SECT 01 0000 \[.text\] Lat0
+0000000000000000 l.*0e SECT 02 0000 \[.data\] Lzd0
+0000000000000002 l.*0e SECT 02 0000 \[.data\] Lmd0
+0000000000000005 l.*0e SECT 02 0000 \[.data\] Lad0
+0000000000000000 l.*0e SECT 03 0000 \[.bss\] zlcomm0
+0000000000000006 l.*0e SECT 03 0000 \[.bss\] mlcomm0
+000000000000000c l.*0e SECT 03 0000 \[.bss\] alcomm0
+0000000000000000 l.*0e SECT 04 0000 \[__HERE.__there\] Lzs0
+0000000000000002 l.*0e SECT 04 0000 \[__HERE.__there\] Lms0
+0000000000000004 l.*0e SECT 04 0000 \[__HERE.__there\] Las0
+000000000000001e l.*0e SECT 01 0000 \[.text\] Lzt1
+0000000000000021 l.*0e SECT 01 0000 \[.text\] Lmt1
+0000000000000023 l.*0e SECT 01 0000 \[.text\] Lat1
+000000000000001e l.*0e SECT 02 0000 \[.data\] Lzd1
+0000000000000020 l.*0e SECT 02 0000 \[.data\] Lmd1
+0000000000000023 l.*0e SECT 02 0000 \[.data\] Lad1
+0000000000000012 l.*0e SECT 03 0000 \[.bss\] zlcomm1
+0000000000000018 l.*0e SECT 03 0000 \[.bss\] mlcomm1
+000000000000001e l.*0e SECT 03 0000 \[.bss\] alcomm1
+0000000000000026 l.*0e SECT 04 0000 \[__HERE.__there\] Lzs1
+0000000000000032 l.*0e SECT 04 0000 \[__HERE.__there\] Lms1
+0000000000000033 l.*0e SECT 04 0000 \[__HERE.__there\] Las1
+0000000000000004 g.*0f SECT 02 0000 \[.data\] adg0
+0000000000000022 g.*0f SECT 02 0000 \[.data\] adg1
+0000000000000005 g.*0f SECT 04 0000 \[__HERE.__there\] asg0
+0000000000000031 g.*0f SECT 04 0000 \[__HERE.__there\] asg1
+0000000000000005 g.*0f SECT 01 0000 \[.text\] atg0
+0000000000000022 g.*0f SECT 01 0000 \[.text\] atg1
+0000000000000003 g.*0f SECT 02 0000 \[.data\] mdg0
+0000000000000021 g.*0f SECT 02 0000 \[.data\] mdg1
+0000000000000003 g.*0f SECT 04 0000 \[__HERE.__there\] msg0
+0000000000000030 g.*0f SECT 04 0000 \[__HERE.__there\] msg1
+0000000000000003 g.*0f SECT 01 0000 \[.text\] mtg0
+0000000000000020 g.*0f SECT 01 0000 \[.text\] mtg1
+0000000000000001 g.*0f SECT 02 0000 \[.data\] zdg0
+000000000000001f g.*0f SECT 02 0000 \[.data\] zdg1
+0000000000000001 g.*0f SECT 04 0000 \[__HERE.__there\] zsg0
+0000000000000027 g.*0f SECT 04 0000 \[__HERE.__there\] zsg1
+0000000000000001 g.*0f SECT 01 0000 \[.text\] ztg0
+000000000000001f g.*0f SECT 01 0000 \[.text\] ztg1
+0000000000000000 g.*01 UND 00 0000 _aud0
+0000000000000000 g.*01 UND 00 0000 _aud1
+0000000000000000 g.*01 UND 00 0000 _aus0
+0000000000000000 g.*01 UND 00 0000 _aus1
+0000000000000000 g.*01 UND 00 0000 _aut0
+0000000000000000 g.*01 UND 00 0000 _mud0
+0000000000000000 g.*01 UND 00 0000 _mud1
+0000000000000000 g.*01 UND 00 0000 _mus0
+0000000000000000 g.*01 UND 00 0000 _mus1
+0000000000000000 g.*01 UND 00 0000 _mut0
+0000000000000000 g.*01 UND 00 0000 _zud0
+0000000000000000 g.*01 UND 00 0000 _zud1
+0000000000000000 g.*01 UND 00 0000 _zus0
+0000000000000000 g.*01 UND 00 0000 _zus1
+0000000000000000 g.*01 UND 00 0000 _zut0
+000000000000000a.*01 COM 00 0300 acommon0
+000000000000000a.*01 COM 00 0300 acommon1
+000000000000000a.*01 COM 00 0300 mcommon0
+000000000000000a.*01 COM 00 0300 mcommon1
+000000000000000a.*01 COM 00 0300 zcommon0
+000000000000000a.*01 COM 00 0300 zcommon1 \ No newline at end of file
diff --git a/gas/testsuite/gas/mach-o/symbols-1.d b/gas/testsuite/gas/mach-o/symbols-1.d
new file mode 100644
index 0000000..cfc1dca
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/symbols-1.d
@@ -0,0 +1,70 @@
+#as: -L
+#objdump: -t
+#target: i?86-*-darwin* powerpc-*-darwin*
+#source: symbols-base.s
+.*: +file format mach-o.*
+#...
+SYMBOL TABLE:
+00000000 l.*0e SECT 01 0000 \[.text\] Lzt0
+00000002 l.*0e SECT 01 0000 \[.text\] Lmt0
+00000004 l.*0e SECT 01 0000 \[.text\] Lat0
+00000000 l.*0e SECT 02 0000 \[.data\] Lzd0
+00000002 l.*0e SECT 02 0000 \[.data\] Lmd0
+00000005 l.*0e SECT 02 0000 \[.data\] Lad0
+00000000 l.*0e SECT 03 0000 \[.bss\] zlcomm0
+00000006 l.*0e SECT 03 0000 \[.bss\] mlcomm0
+0000000c l.*0e SECT 03 0000 \[.bss\] alcomm0
+00000000 l.*0e SECT 04 0000 \[__HERE.__there\] Lzs0
+00000002 l.*0e SECT 04 0000 \[__HERE.__there\] Lms0
+00000004 l.*0e SECT 04 0000 \[__HERE.__there\] Las0
+00000012 l.*0e SECT 01 0000 \[.text\] Lzt1
+00000015 l.*0e SECT 01 0000 \[.text\] Lmt1
+00000017 l.*0e SECT 01 0000 \[.text\] Lat1
+00000012 l.*0e SECT 02 0000 \[.data\] Lzd1
+00000014 l.*0e SECT 02 0000 \[.data\] Lmd1
+00000017 l.*0e SECT 02 0000 \[.data\] Lad1
+00000012 l.*0e SECT 03 0000 \[.bss\] zlcomm1
+00000018 l.*0e SECT 03 0000 \[.bss\] mlcomm1
+0000001e l.*0e SECT 03 0000 \[.bss\] alcomm1
+00000016 l.*0e SECT 04 0000 \[__HERE.__there\] Lzs1
+0000001e l.*0e SECT 04 0000 \[__HERE.__there\] Lms1
+0000001f l.*0e SECT 04 0000 \[__HERE.__there\] Las1
+00000004 g.*0f SECT 02 0000 \[.data\] adg0
+00000016 g.*0f SECT 02 0000 \[.data\] adg1
+00000005 g.*0f SECT 04 0000 \[__HERE.__there\] asg0
+0000001d g.*0f SECT 04 0000 \[__HERE.__there\] asg1
+00000005 g.*0f SECT 01 0000 \[.text\] atg0
+00000016 g.*0f SECT 01 0000 \[.text\] atg1
+00000003 g.*0f SECT 02 0000 \[.data\] mdg0
+00000015 g.*0f SECT 02 0000 \[.data\] mdg1
+00000003 g.*0f SECT 04 0000 \[__HERE.__there\] msg0
+0000001c g.*0f SECT 04 0000 \[__HERE.__there\] msg1
+00000003 g.*0f SECT 01 0000 \[.text\] mtg0
+00000014 g.*0f SECT 01 0000 \[.text\] mtg1
+00000001 g.*0f SECT 02 0000 \[.data\] zdg0
+00000013 g.*0f SECT 02 0000 \[.data\] zdg1
+00000001 g.*0f SECT 04 0000 \[__HERE.__there\] zsg0
+00000017 g.*0f SECT 04 0000 \[__HERE.__there\] zsg1
+00000001 g.*0f SECT 01 0000 \[.text\] ztg0
+00000013 g.*0f SECT 01 0000 \[.text\] ztg1
+00000000 g.*01 UND 00 0000 _aud0
+00000000 g.*01 UND 00 0000 _aud1
+00000000 g.*01 UND 00 0000 _aus0
+00000000 g.*01 UND 00 0000 _aus1
+00000000 g.*01 UND 00 0000 _aut0
+00000000 g.*01 UND 00 0000 _mud0
+00000000 g.*01 UND 00 0000 _mud1
+00000000 g.*01 UND 00 0000 _mus0
+00000000 g.*01 UND 00 0000 _mus1
+00000000 g.*01 UND 00 0000 _mut0
+00000000 g.*01 UND 00 0000 _zud0
+00000000 g.*01 UND 00 0000 _zud1
+00000000 g.*01 UND 00 0000 _zus0
+00000000 g.*01 UND 00 0000 _zus1
+00000000 g.*01 UND 00 0000 _zut0
+0000000a.*01 COM 00 0300 acommon0
+0000000a.*01 COM 00 0300 acommon1
+0000000a.*01 COM 00 0300 mcommon0
+0000000a.*01 COM 00 0300 mcommon1
+0000000a.*01 COM 00 0300 zcommon0
+0000000a.*01 COM 00 0300 zcommon1 \ No newline at end of file
diff --git a/gas/testsuite/gas/mach-o/symbols-base-64.s b/gas/testsuite/gas/mach-o/symbols-base-64.s
new file mode 100644
index 0000000..604501c
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/symbols-base-64.s
@@ -0,0 +1,97 @@
+# baseline symbols in sections.
+Lzt0: .space 1
+ .globl ztg0
+ztg0: .space 1
+Lmt0: .space 1
+ .globl mtg0
+mtg0: .space 1
+Lat0: .space 1
+ .globl atg0
+atg0: .space 1
+
+ .quad _zut0
+ .quad _mut0
+ .quad _aut0
+
+ .comm zcommon0, 10, 3
+ .comm mcommon0, 10, 3
+ .comm acommon0, 10, 3
+
+ .data
+Lzd0: .space 1
+ .globl zdg0
+zdg0: .space 1
+Lmd0: .space 1
+ .globl mdg0
+mdg0: .space 1
+adg0: .space 1
+ .globl adg0
+Lad0: .space 1
+
+ .quad _zud0
+ .quad _mud0
+ .quad _aud0
+
+ .lcomm zlcomm0, 5, 1
+ .lcomm mlcomm0, 5, 1
+ .lcomm alcomm0, 5, 1
+
+ .section __HERE,__there
+Lzs0: .space 1
+ .globl zsg0
+zsg0: .space 1
+Lms0: .space 1
+ .globl msg0
+msg0: .space 1
+Las0: .space 1
+asg0: .space 1
+ .globl asg0
+
+ .quad _zus0
+ .quad _mus0
+ .quad _aus0
+
+ .text
+Lzt1: .space 1
+ .globl ztg1
+ztg1: .space 1
+ .globl mtg1
+mtg1: .space 1
+Lmt1: .space 1
+atg1: .space 1
+ .globl atg1
+Lat1: .space 1
+
+ .comm zcommon1, 10, 3
+ .comm mcommon1, 10, 3
+ .comm acommon1, 10, 3
+
+ .data
+Lzd1: .space 1
+ .globl zdg1, mdg1, adg1
+zdg1: .space 1
+Lmd1: .space 1
+mdg1: .space 1
+adg1: .space 1
+Lad1: .space 1
+
+ .quad _zud1
+ .quad _mud1
+ .quad _aud1
+
+ .lcomm zlcomm1, 5, 1
+ .lcomm mlcomm1, 5, 1
+ .lcomm alcomm1, 5, 1
+
+ .section __HERE,__there
+ .quad _zus1
+Lzs1: .space 1
+zsg1: .space 1
+ .quad _mus1
+msg1: .space 1
+asg1: .space 1
+ .globl zsg1, msg1, asg1
+Lms1: .space 1
+Las1: .space 1
+
+ .quad _aus1
diff --git a/gas/testsuite/gas/mach-o/symbols-base.s b/gas/testsuite/gas/mach-o/symbols-base.s
new file mode 100644
index 0000000..a7b8e75
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/symbols-base.s
@@ -0,0 +1,97 @@
+# baseline symbols in sections.
+Lzt0: .space 1
+ .globl ztg0
+ztg0: .space 1
+Lmt0: .space 1
+ .globl mtg0
+mtg0: .space 1
+Lat0: .space 1
+ .globl atg0
+atg0: .space 1
+
+ .long _zut0
+ .long _mut0
+ .long _aut0
+
+ .comm zcommon0, 10, 3
+ .comm mcommon0, 10, 3
+ .comm acommon0, 10, 3
+
+ .data
+Lzd0: .space 1
+ .globl zdg0
+zdg0: .space 1
+Lmd0: .space 1
+ .globl mdg0
+mdg0: .space 1
+adg0: .space 1
+ .globl adg0
+Lad0: .space 1
+
+ .long _zud0
+ .long _mud0
+ .long _aud0
+
+ .lcomm zlcomm0, 5, 1
+ .lcomm mlcomm0, 5, 1
+ .lcomm alcomm0, 5, 1
+
+ .section __HERE,__there
+Lzs0: .space 1
+ .globl zsg0
+zsg0: .space 1
+Lms0: .space 1
+ .globl msg0
+msg0: .space 1
+Las0: .space 1
+asg0: .space 1
+ .globl asg0
+
+ .long _zus0
+ .long _mus0
+ .long _aus0
+
+ .text
+Lzt1: .space 1
+ .globl ztg1
+ztg1: .space 1
+ .globl mtg1
+mtg1: .space 1
+Lmt1: .space 1
+atg1: .space 1
+ .globl atg1
+Lat1: .space 1
+
+ .comm zcommon1, 10, 3
+ .comm mcommon1, 10, 3
+ .comm acommon1, 10, 3
+
+ .data
+Lzd1: .space 1
+ .globl zdg1, mdg1, adg1
+zdg1: .space 1
+Lmd1: .space 1
+mdg1: .space 1
+adg1: .space 1
+Lad1: .space 1
+
+ .long _zud1
+ .long _mud1
+ .long _aud1
+
+ .lcomm zlcomm1, 5, 1
+ .lcomm mlcomm1, 5, 1
+ .lcomm alcomm1, 5, 1
+
+ .section __HERE,__there
+ .long _zus1
+Lzs1: .space 1
+zsg1: .space 1
+ .long _mus1
+msg1: .space 1
+asg1: .space 1
+ .globl zsg1, msg1, asg1
+Lms1: .space 1
+Las1: .space 1
+
+ .long _aus1