diff options
author | Dave Korn <dave.korn@artimi.com> | 2009-05-19 16:08:08 +0000 |
---|---|---|
committer | Dave Korn <dave.korn@artimi.com> | 2009-05-19 16:08:08 +0000 |
commit | c1711530e652a14bc0df9b603c73e350b5dfe5ec (patch) | |
tree | f0e82c9c384277dc508547d786bbc912eac7edf8 /gas/config/obj-coff.c | |
parent | fbdebf465713844d23625ae09e0ae4995418328b (diff) | |
download | gdb-c1711530e652a14bc0df9b603c73e350b5dfe5ec.zip gdb-c1711530e652a14bc0df9b603c73e350b5dfe5ec.tar.gz gdb-c1711530e652a14bc0df9b603c73e350b5dfe5ec.tar.bz2 |
==> bfd/ChangeLog <==
2009-05-19 Dave Korn <dave.korn.cygwin@gmail.com>
* cofflink.c (process_embedded_commands): Ignore "-aligncomm".
==> gas/ChangeLog <==
2009-05-19 Dave Korn <dave.korn.cygwin@gmail.com>
* NEWS: Mention new feature.
* config/obj-coff.c (obj_coff_common_parse): New function.
(obj_coff_comm): Likewise.
(coff_pseudo_table): Override default ".comm" definition on PE.
* doc/as.texinfo: Document new feature.
==> gas/testsuite/ChangeLog <==
2009-05-19 Dave Korn <dave.korn.cygwin@gmail.com>
* gas/pe/: New directory for PE format-specific tests.
* gas/pe/aligncomm-a.d: New test pattern file.
* gas/pe/aligncomm-a.s: New test source file.
* gas/pe/aligncomm-b.d: New test pattern file.
* gas/pe/aligncomm-b.s: New test source file.
* gas/pe/aligncomm-c.d: New test pattern file.
* gas/pe/aligncomm-c.s: New test source file.
* gas/pe/aligncomm-d.d: New test pattern file.
* gas/pe/aligncomm-d.s: New test source file.
* gas/pe/pe.exp: New test control script.
* lib/gas-defs.exp (is_pecoff_format): New function.
==> ld/ChangeLog <==
2009-05-19 Dave Korn <dave.korn.cygwin@gmail.com>
* NEWS: Mention new feature.
* deffile.h (def_file_aligncomm): Add new struct definition.
(def_file): Add new def_file_aligncomm member.
* deffilep.y (%token): Add new ALIGNCOMM token.
(command): Add production rule for ALIGNCOMM.
(def_file_free): Free any chained def_file_aligncomm structs.
(diropts[]): Add entry for '-aligncomm' .drectve command.
(def_aligncomm): New grammar function.
* ld.texinfo: Document new feature.
* pe-dll.c (process_def_file): Rename from this ...
(process_def_file_and_drectve): ... to this, updating all callers,
and process any aligncomms chained to the def file after scanning
all .drectve sections.
(generate_edata): Updated to match.
(pe_dll_build_sections): Likewise.
==> ld/testsuite/ChangeLog <==
2009-05-19 Dave Korn <dave.korn.cygwin@gmail.com>
* ld-pe/aligncomm-1.c: New test source file.
* ld-pe/aligncomm-2.c: Likewise.
* ld-pe/aligncomm-3.c: Likewise.
* ld-pe/aligncomm-4.c: Likewise.
* ld-pe/aligncomm.d: New test pattern file.
* ld-pe/direct.exp: Deleted, and content moved into ...
* ld-pe/pe-run.exp: ... New common file for all PE run tests.
* ld-pe/vers-script.exp: Deleted, and content merged into ...
* ld-pe/pe-compile.exp: ... New common file for PE tests needing
a compiler, adding aligned common tests.
* ld-pe/pe.exp: Update header comment.
Diffstat (limited to 'gas/config/obj-coff.c')
-rw-r--r-- | gas/config/obj-coff.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index b2f4558..98d8d6c 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -169,6 +169,71 @@ obj_coff_bss (int ignore ATTRIBUTE_UNUSED) s_lcomm (0); } +#ifdef TE_PE +/* Called from read.c:s_comm after we've parsed .comm symbol, size. + Parse a possible alignment value. */ + +static symbolS * +obj_coff_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, addressT size) +{ + addressT align = 0; + + if (*input_line_pointer == ',') + { + align = parse_align (0); + if (align == (addressT) -1) + return NULL; + } + + S_SET_VALUE (symbolP, size); + S_SET_EXTERNAL (symbolP); + S_SET_SEGMENT (symbolP, bfd_com_section_ptr); + + symbol_get_bfdsym (symbolP)->flags |= BSF_OBJECT; + + /* There is no S_SET_ALIGN (symbolP, align) in COFF/PE. + Instead we must add a note to the .drectve section. */ + if (align) + { + segT current_seg = now_seg; + subsegT current_subseg = now_subseg; + flagword oldflags; + asection *sec; + size_t pfxlen, numlen; + char *frag; + char numbuff[20]; + + sec = subseg_new (".drectve", 0); + oldflags = bfd_get_section_flags (stdoutput, sec); + if (oldflags == SEC_NO_FLAGS) + { + if (!bfd_set_section_flags (stdoutput, sec, + TC_COFF_SECTION_DEFAULT_ATTRIBUTES)) + as_warn (_("error setting flags for \"%s\": %s"), + bfd_section_name (stdoutput, sec), + bfd_errmsg (bfd_get_error ())); + } + + /* Emit a string. Note no NUL-termination. */ + pfxlen = strlen (" -aligncomm:") + strlen (S_GET_NAME (symbolP)) + 1; + numlen = snprintf (numbuff, sizeof (numbuff), "%d", (int) align); + frag = frag_more (pfxlen + numlen); + (void) sprintf (frag, " -aligncomm:%s,", S_GET_NAME (symbolP)); + memcpy (frag + pfxlen, numbuff, numlen); + /* Restore original subseg. */ + subseg_set (current_seg, current_subseg); + } + + return symbolP; +} + +static void +obj_coff_comm (int ignore ATTRIBUTE_UNUSED) +{ + s_comm_internal (ignore, obj_coff_common_parse); +} +#endif /* TE_PE */ + #define GET_FILENAME_STRING(X) \ ((char *) (&((X)->sy_symbol.ost_auxent->x_file.x_n.x_offset))[1]) @@ -1784,6 +1849,10 @@ const pseudo_typeS coff_pseudo_table[] = /* We accept the .bss directive for backward compatibility with earlier versions of gas. */ {"bss", obj_coff_bss, 0}, +#ifdef TE_PE + /* PE provides an enhanced version of .comm with alignment. */ + {"comm", obj_coff_comm, 0}, +#endif /* TE_PE */ {"def", obj_coff_def, 0}, {"dim", obj_coff_dim, 0}, {"endef", obj_coff_endef, 0}, |