This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
>>> James E Wilson <wilson@specifixinc.com> 15.02.05 00:48:25 >>> >On Mon, 2005-02-14 at 00:36, Jan Beulich wrote: >> The question thus is: Should the assembler continue to violate the spec >> and allow .xdata to create sections (in which case the second change >> would be at least desirable), or should it be fixed, in which case >> probably calling obj_elf_change_section might not be necessary at all >> anymore, thus allowing to free the allocated name string. > >HJ's example comes from glibc. Since we are trying to avoid >unnecessarily breaking backwards compatibility, that means we can only >emit a warning here for now. So we have to go with the former solution >for now, which means continuing to create sections while warning about >it, and adding a comment to indicate a possible future cleanup which >makes this an error and allows us to free the string. This fixes not only the memory leaks that all the .xdata family directives experienced, but also inconsistencies on uncommon section names used here (these could get parsed twice, leading to unexpected results). Further, the .xrealN.ua sub-family of directives no longer incorrectly forces alignment. And finally, creation of sections through any of the .xdata family directives now gets a warning. Built and tested on ia64-unknown-linux-gnu. Jan gas/ 2005-02-28 Jan Beulich <jbeulich@novell.com> * config/tc-ia64.c (parse_section_name): Rename to... (cross_section): In addition to separating the name from the rest of the arguments, also carry out the operation. (dot_xdata): Use cross_section. (dot_float_cons): Likewise. (dot_xstringer): Likewise. (dot_xdata_ua): Likewise. (dot_float_cons_ua): Likewise. Pass float_cons, not stmt_float_cons. gas/testsuite/ 2005-02-28 Jan Beulich <jbeulich@novell.com> * gas/ia64/xdata.[sd], gas/ia64/xdata-ilp32.d: New. * gas/ia64/ia64.exp: Run new tests. --- /home/jbeulich/src/binutils/mainline/2005-02-28/gas/config/tc-ia64.c 2005-02-28 08:27:15.000000000 +0100 +++ 2005-02-28/gas/config/tc-ia64.c 2005-02-28 14:47:27.719234860 +0100 @@ -765,7 +765,7 @@ static void dot_byteorder PARAMS ((int)) static void dot_psr PARAMS ((int)); static void dot_alias PARAMS ((int)); static void dot_ln PARAMS ((int)); -static char *parse_section_name PARAMS ((void)); +static void cross_section PARAMS ((int ref, void (*cons) PARAMS((int)), int ua)); static void dot_xdata PARAMS ((int)); static void stmt_float_cons PARAMS ((int)); static void stmt_cons_ua PARAMS ((int)); @@ -4757,58 +4757,75 @@ dot_ln (dummy) demand_empty_rest_of_line (); } -static char * -parse_section_name () -{ - char *name; - int len; +static void +cross_section (ref, cons, ua) + int ref; + void (*cons) PARAMS((int)); + int ua; +{ + char *start, *end; + int saved_auto_align; + unsigned int section_count; SKIP_WHITESPACE (); - if (*input_line_pointer == '"') + start = input_line_pointer; + if (*start == '"') + { + int len; + char *name; + name = demand_copy_C_string (&len); + obstack_free(¬es, name); + if (!name) + { + ignore_rest_of_line (); + return; + } + } else { - char *start = input_line_pointer; char c = get_symbol_end (); if (input_line_pointer == start) { as_bad ("Missing section name"); ignore_rest_of_line (); - return 0; + return; } - name = obstack_copy (¬es, start, input_line_pointer - start + 1); *input_line_pointer = c; } - if (!name) - { - ignore_rest_of_line (); - return 0; - } + end = input_line_pointer; SKIP_WHITESPACE (); if (*input_line_pointer != ',') { as_bad ("Comma expected after section name"); ignore_rest_of_line (); - return 0; + return; } - ++input_line_pointer; /* skip comma */ - return name; + *end = '\0'; + end = input_line_pointer + 1; /* skip comma */ + input_line_pointer = start; + md.keep_pending_output = 1; + section_count = bfd_count_sections(stdoutput); + obj_elf_section (0); + if (section_count != bfd_count_sections(stdoutput)) + as_warn ("Creating sections with .xdataN/.xrealN/.xstringZ is deprecated."); + input_line_pointer = end; + saved_auto_align = md.auto_align; + if (ua) + md.auto_align = 0; + (*cons) (ref); + if (ua) + md.auto_align = saved_auto_align; + obj_elf_previous (0); + md.keep_pending_output = 0; } static void dot_xdata (size) int size; { - char *name = parse_section_name (); - if (!name) - return; - - md.keep_pending_output = 1; - set_section (name); - cons (size); - obj_elf_previous (0); - md.keep_pending_output = 0; + cross_section (size, cons, 0); } /* Why doesn't float_cons() call md_cons_align() the way cons() does? */ @@ -4854,66 +4871,28 @@ static void dot_xfloat_cons (kind) int kind; { - char *name = parse_section_name (); - if (!name) - return; - - md.keep_pending_output = 1; - set_section (name); - stmt_float_cons (kind); - obj_elf_previous (0); - md.keep_pending_output = 0; + cross_section (kind, stmt_float_cons, 0); } static void dot_xstringer (zero) int zero; { - char *name = parse_section_name (); - if (!name) - return; - - md.keep_pending_output = 1; - set_section (name); - stringer (zero); - obj_elf_previous (0); - md.keep_pending_output = 0; + cross_section (zero, stringer, 0); } static void dot_xdata_ua (size) int size; { - int saved_auto_align = md.auto_align; - char *name = parse_section_name (); - if (!name) - return; - - md.keep_pending_output = 1; - set_section (name); - md.auto_align = 0; - cons (size); - md.auto_align = saved_auto_align; - obj_elf_previous (0); - md.keep_pending_output = 0; + cross_section (size, cons, 1); } static void dot_xfloat_cons_ua (kind) int kind; { - int saved_auto_align = md.auto_align; - char *name = parse_section_name (); - if (!name) - return; - - md.keep_pending_output = 1; - set_section (name); - md.auto_align = 0; - stmt_float_cons (kind); - md.auto_align = saved_auto_align; - obj_elf_previous (0); - md.keep_pending_output = 0; + cross_section (kind, float_cons, 1); } /* .reg.val <regname>,value */ --- /home/jbeulich/src/binutils/mainline/2005-02-28/gas/testsuite/gas/ia64/ia64.exp 2005-02-28 08:27:22.000000000 +0100 +++ 2005-02-28/gas/testsuite/gas/ia64/ia64.exp 2005-02-28 14:43:55.943846829 +0100 @@ -64,10 +64,12 @@ if [istarget "ia64-*"] then { run_dump_test "secname-ilp32" run_dump_test "unwind-ilp32" run_dump_test "alias-ilp32" + run_dump_test "xdata-ilp32" } else { run_dump_test "secname" run_dump_test "unwind" run_dump_test "alias" + run_dump_test "xdata" run_dump_test "group-1" } --- /home/jbeulich/src/binutils/mainline/2005-02-28/gas/testsuite/gas/ia64/xdata-ilp32.d 1970-01-01 01:00:00.000000000 +0100 +++ 2005-02-28/gas/testsuite/gas/ia64/xdata-ilp32.d 2005-02-28 15:04:49.053206478 +0100 @@ -0,0 +1,29 @@ +#readelf: -S +#name: ia64 xdata (ilp32) +#as: -milp32 +#source: xdata.s + +There are 19 section headers, starting at offset 0x[[:xdigit:]]+: + +Section Headers: + \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al + \[ 0\] NULL 00000000 000000 000000 00 0 0 0 + \[ 1\] .text PROGBITS 00000000 [[:xdigit:]]+ 000000 00 AX 0 0 16 + \[ 2\] .data PROGBITS 00000000 [[:xdigit:]]+ 000000 00 WA 0 0 1 + \[ 3\] .bss NOBITS 00000000 [[:xdigit:]]+ 000000 00 WA 0 0 1 + \[ 4\] \.xdata1 PROGBITS 00000000 [[:xdigit:]]+ 000001 00 A 0 0 1 + \[ 5\] \.xdata2 PROGBITS 00000000 [[:xdigit:]]+ 000004 00 A 0 0 2 + \[ 6\] ,xdata3 PROGBITS 00000000 [[:xdigit:]]+ 000008 00 A 0 0 4 + \[ 7\] \.xdata,4 PROGBITS 00000000 [[:xdigit:]]+ 000010 00 A 0 0 8 + \[ 8\] "\.xdata5" PROGBITS 00000000 [[:xdigit:]]+ 000020 00 A 0 0 16 + \[ 9\] \.rela"\.xdata5" RELA 00000000 [[:xdigit:]]+ 000018 0c 17 8 4 + \[10\] \.xreal\\1 PROGBITS 00000000 [[:xdigit:]]+ 000008 00 A 0 0 4 + \[11\] \.xreal\+2 PROGBITS 00000000 [[:xdigit:]]+ 000010 00 A 0 0 8 + \[12\] \.xreal\(3\) PROGBITS 00000000 [[:xdigit:]]+ 000014 00 A 0 0 16 + \[13\] \.xreal\[4\] PROGBITS 00000000 [[:xdigit:]]+ 000020 00 A 0 0 16 + \[14\] \.xstr<1> PROGBITS 00000000 [[:xdigit:]]+ 000003 00 A 0 0 1 + \[15\] \.xstr\{2\} PROGBITS 00000000 [[:xdigit:]]+ 000004 00 A 0 0 1 + \[16\] .shstrtab STRTAB 00000000 [[:xdigit:]]+ [[:xdigit:]]+ 00 0 0 1 + \[17\] .symtab SYMTAB 00000000 [[:xdigit:]]+ [[:xdigit:]]+ 10 18 15 4 + \[18\] .strtab STRTAB 00000000 [[:xdigit:]]+ [[:xdigit:]]+ 00 0 0 1 +#pass --- /home/jbeulich/src/binutils/mainline/2005-02-28/gas/testsuite/gas/ia64/xdata.d 1970-01-01 01:00:00.000000000 +0100 +++ 2005-02-28/gas/testsuite/gas/ia64/xdata.d 2005-02-28 15:04:16.838363123 +0100 @@ -0,0 +1,47 @@ +#readelf: -S +#name: ia64 xdata + +There are 19 section headers, starting at offset 0x[[:xdigit:]]+: + +Section Headers: + \[Nr\] Name Type Address Offset + Size EntSize Flags Link Info Align + \[ 0\] NULL 0000000000000000 [[:xdigit:]]+ + 0000000000000000 0000000000000000 0 0 0 + \[ 1\] \.text PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000000 0000000000000000 AX 0 0 16 + \[ 2\] \.data PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000000 0000000000000000 WA 0 0 1 + \[ 3\] \.bss NOBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000000 0000000000000000 WA 0 0 1 + \[ 4\] \.xdata1 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000001 0000000000000000 A 0 0 1 + \[ 5\] \.xdata2 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000004 0000000000000000 A 0 0 2 + \[ 6\] ,xdata3 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000008 0000000000000000 A 0 0 4 + \[ 7\] \.xdata,4 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000010 0000000000000000 A 0 0 8 + \[ 8\] "\.xdata5" PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000020 0000000000000000 A 0 0 16 + \[ 9\] \.rela"\.xdata5" RELA 0000000000000000 [[:xdigit:]]+ + 0000000000000030 0000000000000018 17 8 8 + \[10\] \.xreal\\1 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000008 0000000000000000 A 0 0 4 + \[11\] \.xreal\+2 PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000010 0000000000000000 A 0 0 8 + \[12\] \.xreal\(3\) PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000014 0000000000000000 A 0 0 16 + \[13\] \.xreal\[4\] PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000020 0000000000000000 A 0 0 16 + \[14\] \.xstr<1> PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000003 0000000000000000 A 0 0 1 + \[15\] \.xstr\{2\} PROGBITS 0000000000000000 [[:xdigit:]]+ + 0000000000000004 0000000000000000 A 0 0 1 + \[16\] \.shstrtab STRTAB 0000000000000000 [[:xdigit:]]+ + [[:xdigit:]]+ 0000000000000000 0 0 1 + \[17\] \.symtab SYMTAB 0000000000000000 [[:xdigit:]]+ + [[:xdigit:]]+ 0000000000000018 18 15 8 + \[18\] \.strtab STRTAB 0000000000000000 [[:xdigit:]]+ + [[:xdigit:]]+ 0000000000000000 0 0 1 +#pass --- /home/jbeulich/src/binutils/mainline/2005-02-28/gas/testsuite/gas/ia64/xdata.s 1970-01-01 01:00:00.000000000 +0100 +++ 2005-02-28/gas/testsuite/gas/ia64/xdata.s 2005-02-28 10:54:12.000000000 +0100 @@ -0,0 +1,39 @@ +.section .xdata1, "a", @progbits +.section ".xdata2", "a", @progbits +.section ",xdata3", "a", @progbits +.section ".xdata,4", "a", @progbits +.section "\".xdata5\"", "a", @progbits + +.section ".xreal\\1", "a", @progbits +.section ".xreal+2", "a", @progbits +.section ".xreal(3)", "a", @progbits +.section ".xreal[4]", "a", @progbits + +.section ".xstr<1>", "a", @progbits +.section ".xstr{2}", "a", @progbits + +.text + +.xdata1 .xdata1, 1 +.xdata2 ".xdata2", 2 +.xdata4 ",xdata3", 3 +.xdata8 ".xdata,4", 4 +.xdata16 "\".xdata5\"", @iplt(_start) + +.xdata2.ua ".xdata2", 2 +.xdata4.ua ",xdata3", 3 +.xdata8.ua ".xdata,4", 4 +.xdata16.ua "\".xdata5\"", @iplt(_start) + +.xreal4 ".xreal\\1", 1 +.xreal8 ".xreal+2", 2 +.xreal10 ".xreal(3)", 3 +.xreal16 ".xreal[4]", 4 + +.xreal4.ua ".xreal\\1", 1 +.xreal8.ua ".xreal+2", 2 +.xreal10.ua ".xreal(3)", 3 +.xreal16.ua ".xreal[4]", 4 + +.xstring ".xstr<1>", "abc" +.xstringz ".xstr{2}", "xyz"
Attachment:
binutils-mainline-ia64-xdata-2.patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |