Commit Graph

77 Commits

Author SHA1 Message Date
Ian Lance Taylor
5ac34ac37e * Extensive changes to permit symbols to contain any expression
type and to delay the computation of the expression until the
	value is actually needed.  This permits setting symbols to values
	calculated based on object code size.  Expressions were changed to
	no longer be in a section, to stop the overloading of segment and
	expression type that previously occurred.

	* as.c (big_section, pass1_section, diff_section, absent_section):
	Removed.
	(expr_section): Added (used for dummy symbols which hold
	intermediate expression values).
	(perform_an_assembly_pass): Create expr_section, do not create the
	sections now removed.
	* as.h (segT): Removed SEG_ABSENT, SEG_PASS1, SEG_BIG, and
	SEG_DIFFERENCE.  Added SEG_EXPR.
	(SEG_NORMAL): Corresponding changes.
	* subsegs.c (seg_name, subsegs_begin): Changed accordingly.
	* write.c (write_object_file): Ditto.
	* config/obj-aout.c (seg_N_TYPE): Ditto.
	* config/obj-bout.c (seg_N_TYPE): Ditto.
	* config/obj-coff.c (seg_N_TYPE): Ditto.
	* config/obj-coffbfd.c (seg_N_TYPE): Ditto.
	* config/obj-vms.c (seg_N_TYPE): Ditto.

	* expr.h (operatorT): Moved in from expr.c, added some values.
	(expressionS): Added X_op field, removed X_seg field; renamed
	X_subtract_symbol to X_op_symbol.
	* expr.c: Extensive changes to assign expression types rather than
	sections and to simplify the parsing.
	* write.c (fix_new_internal): New static function.
	(fix_new): Removed sub_symbol argument.
	(fix_new_exp): New function, takes expression argument.
	* write.h: Prototype changes for fix_new and fix_new_exp.
	* cond.c (s_if): Changed accordingly.
	* read.c (s_lsym, pseudo_set, emit_expr, parse_bitfield_cons,
	parse_repeat_cons, get_segmented_expression,
	get_known_segmented_expression, get_absolute_expression): Ditto.
	* symbols.c (resolve_symbol_value, S_GET_VALUE, S_SET_VALUE):
	Ditto.
	* write.c (write_object_file): Ditto.
	* config/obj-coff.c (obj_coff_def, obj_coff_val): Ditto.
	* config/obj-coffbfd.c (obj_coff_def, obj_coff_val,
	obj_coff_endef, yank_symbols): Ditto.
	* config/obj-elf.c (obj_elf_stab_generic, obj_elf_size): Ditto.
	* config/tc-a29k.c (md_assemble, parse_operand, machine_ip,
	print_insn, md_operand): Ditto.
	* config/tc-h8300.c (parse_exp, colonmod24, check_operand,
	do_a_fix_imm, build_bytes): Ditto.
	* config/tc-h8500.c (parse_exp, skip_colonthing, parse_reglist,
	get_specific, check, insert, md_convert_frag): Ditto.
	* config/tc-hppa.c (the_insn, fix_new_hppa, cons_fix_new_hppa,
	md_assemble, pa_ip, getExpression, getAbsoluteExpression,
	evaluateAbsolute, pa_build_unwind_subspace, pa_entry,
	process_exit): Ditto.
	* config/tc-hppa.h (STAB_FIXUP, is_DP_relative, is_PC_relative,
	is_complex): Ditto.
	* config/tc-i386.c (pe, md_assemble, i386_operand,
	md_estimate_size_before_relax, md_create_long_jump): Ditto.
	* config/tc-i860.c (md_assemble, getExpression, print_insn):
	Ditto.
	* config/tc-i960.c (parse_expr, subs, segs, md_convert_frag,
	get_cdisp, mem_fmt, parse_ldconst, relax_cobr, s_sysproc,
	i960_handle_align): Ditto.
	* config/tc-m68k.c (struct m68k_exp, struct m68k_it, seg, op,
	subs, add_fix, isvar, m68k_ip, md_assemble, md_convert_frag_1,
	md_estimate_size_before_relax, md_create_long_jump, get_num):
	Ditto.
	* config/tc-m88k.c (md_assemble, get_imm16, get_pcr,
	md_create_short_jump, md_create_long_jump): Ditto.
	* config/tc-mips.c (md_assemble, append_insn, gp_reference,
	macro_build, macro, my_getExpression): Ditto.  Also removed
	get_optional_absolute_expression; just use get_absolute_expression
	instead.
	* config/tc-ns32k.c (get_addr_mode, evaluate_expr, convert_iif,
	fix_new_ns32k, fix_new_ns32k_exp, cons_fix_new_ns32k): Ditto.
	* config/tc-ns32k.h (fix_new_ns32k prototype): Ditto.
	* config/tc-sh.c (parse_exp, check, insert, md_convert_frag):
	Ditto.
	* config/tc-sparc.c (md_assemble, sparc_ip, getExpression,
	print_insn): Ditto.
	* config/tc-tahoe.c (struct top, md_estimate_size_before_relax,
	tip_op, md_assemble): Ditto.
	* config/tc-vax.c (seg_of_operand, md_assemble,
	md_estimate_size_before_relax, md_create_long_jump): Ditto.
	* config/tc-z8k.c (parse_exp, check_operand, newfix): Ditto.
1993-07-21 00:41:42 +00:00
Ken Raeburn
8d6c34a108 (write_relocs): New function, split off from write_contents. Use memset
instead of bzero.
(write_object_file): Apply write_relocs to each section before applying
write_contents.
1993-07-19 20:05:16 +00:00
Ian Lance Taylor
5868b1fe68 * Removed sy_forward and replaced it with an undefined expression
as the value of a symbol.
	* struc-symbol.h (struct symbol): Removed sy_forward field.  Added
	sy_resolved and sy_resolving single bit fields.
	* symbols.c (symbol_new): Don't initialize sy_forward field.
	(resolve_symbol_value): New function to adjust symbol value by
	fragment address, using recursion to resolve forward symbols.
	* symbols.h: Added prototype for new function.
	* read.c (pseudo_set): Set symbolP->sy_value to an undefined
	expression rather than setting symbolP->sy_forward.
	* write.c (write_object_file): Use resolve_symbol_value on
	symbols, keeping the common case (the old behaviour) inline.
	* config/obj-aout.c (obj_aout_frob_symbol): Removed sy_forward
	handling (subsumed by write.c change).
	* config/obj-coff.c, config/obj-coffbfd.c (obj_coff_val): Set
	sy_value rather than sy_forward.
	* config/obj-coffbfd.c (obj_coff_endef, yank_symbols): Check
	expression segment rather than sy_forward.
	(yank_symbols): Use resolve_symbol_value.
	(crawl_symbols): Removed extra pass over symbols.
	* config/obj-aout.c, config/obj-bout.c, config/obj-coff.c,
	config/obj-vms.c (obj_crawl_symbol_chain): Removed extra pass over
	symbols which handled sy_forward; use resolve_symbol_value
	instead.
	* config/obj-coff.h, config/obj-coffbfd.h (obj_frob_forward_symbol):
	Define.
	* config/obj-elf.c (obj_elf_stab_generic): Check expression
	segment rather than sy_forward.
	* config/obj-vms.c (VMS_Check_For_Main): Don't initialize
	sy_forward; do initialize sy_resolved and sy_resolving.
	* config/tc-hppa.h (STAB_FIXUP): Use sy_value, not sy_forward.
1993-07-14 22:21:25 +00:00
Ian Lance Taylor
85051959f4 * Changes to keep a full expression as the value of a symbol, not
just a longword:
	* struc-symbol.h: New field sy_value.
	* as.h: Include expr.h before struc-symbol.h.
	* expr.h: Use struct symbol rather than symbolS.
	* symbols.c (S_GET_VALUE, S_SET_VALUE): Rewrote to retrieve value
	of sy_value field; compile unconditionally, not just if
	BFD_ASSEMBLER.
	* symbols.h: Compile S_{SG}ET_VALUE prototypes unconditionally.
	* write.c (write_object_file): Set BFD symbol value to gas symbol
	value.
	* config/obj-aout.h, config/obj-bout.h, config/obj-coff.h,
	config/obj-coffbfd.h, config/obj-generic.h, config/obj-vms.h
	(S_GET_VALUE, S_SET_VALUE): Removed macro definitions.
	* config/obj-ieee.c (S_GET_VALUE, S_SET_VALUE): Removed.
	* config/obj-coff.h, obj-coffbfd.h: Rewrote several macros to use
	S_GET_VALUE rather than ost_entry.n_value.
	* config/obj-aout.c (obj_symbol_to_chars), config/obj-bout.c
	(obj_symbol_to_chars), config/obj-coff.c (obj_symbol_to_chars),
	config/obj-coffbfd.c (symbol_to_chars): Get value to write out
	using S_GET_VALUE--don't assume it is already set.
	* config/obj-ieee.c (do_symbols): Set BFD symbol value to gas
	symbol value.
	* config/obj-vms.c (various): Don't assign directly to
	S_GET_VALUE; use S_SET_VALUE instead.
1993-07-14 19:35:45 +00:00
Ken Raeburn
d536474829 (write_object_file): Locals from_addr, to_addr, table_addr are now addressT.
Supply prototype for bfd_alloc for now.
(fixup_segment): Local add_number is now valueT.  Fix some range-checking bugs.
(relax_align): Type `int' should be sufficient for the exponent.
(fix_new): Argument offset is offsetT.  Locals size and newsize are valueT.
1993-07-07 16:33:38 +00:00
Ian Lance Taylor
3d3c503955 * write.c (write_contents): Compute the relocs before writing out
the section contents.
	* config/obj-ecoff.h, config/obj-ecoff.c: Numerous changes to get
	symbol table and values right.
	* config/tc-mips.h (LOCAL_LABEL): If OBJ_ECOFF, any label starting
	with $L is local.
	* config/tc-mips.c (tc_gen_reloc): If OBJ_ECOFF, adjust the addend
	by the section vma.

	* config/z8k.mt (TARG_CPU_DEPENDENTS): The relevant file is
	z8k-opc.h, not z8k.h.
1993-03-15 23:58:22 +00:00
Ian Lance Taylor
f2f7d044cd * expr.c, write.c: Ultrix native 4.2 cc requires assert condition
to be on a single line.
1993-03-12 20:01:28 +00:00
Ken Raeburn
43ca9aa677 set SEC_RELOC only if fixups are required 1993-03-02 17:05:34 +00:00
Ian Lance Taylor
85825401dc Wed Dec 30 10:18:57 1992 Ian Lance Taylor (ian@cygnus.com)
* app.c, config/tc-*.c: Don't include read.h, since it is already
	included by as.h.

	* These are based on patches from Minh Tran-le
	<mtranle@paris.intellicorp.com>.
	* configure.in (i[34]86-ibm-aix*): Accept i486 for host.  Use
	obj_format coffbfd and gas_target i386coff for target.
	(i[34]86-*-isc*): New host (uses sysv).
	* config/i386aix.mt: Removed (no longer used).
	* config/mh-i386aix (RANLIB): Use true rather than /bin/true.
	(MINUS_G): Removed.
	(LDFLAGS): Added, defined as -shlib.
	* config/te-i386aix.h (REVERSE_SORT_RELOCS): Undefine.
	* config/te-sco386.h (LOCAL_LABEL): Don't define.
	(DOT_LABEL_PREFIX): Define.
	* expr.c (operand): If DOT_LABEL_PREFIX, use .L0\001 as a label
	name rather than L0\001.
	* read.c (s_lcomm): Make a frag in SEG_BSS rather than using
	local_bss_counter.
	* symbols.c, symbols.h (local_bss_counter): Removed.
	* write.c (write_object_file): bss no longer uses
	local_bss_counter.  Pass correct data and bss size to
	VMS_write_object_file.
	* config/obj-vms.c (VMS_write_object_file): Accept bss size as
	argument, rather than using local_bss_counter.
	* config/tc-m88k.c (s_bss): Don't use local_bss_counter.
	* config/tc-sparc.c (s_reserve): Don't use local_bss_counter.
	* config/obj-coffbfd.c (had_lineno, had_reloc): Removed.
	(size_section): Restored sanity check.
	(do_relocs_for): Base section address on s_paddr rather than
	computing it.  Adjust a29k R_IHIHALF special case to account for
	section paddr (used to require paddr to be zero).  If there are no
	reclos, set s_relptr to 0.  Set relocation size in object_headers.
	(fill_section): Always set s_vaddr here, removing
	ZERO_BASED_SEGMENTS case.  Force s_scnptr for bss to 0.  Don't set
	NOLOAD for i386 .bss, because it confuses the SVR3 native linker.
	Set STYP_INFO for .comment.
	(coff_header_append): Use object headers and H_{SET,GET}_* macros.
	Make aouthdr writing depend on OBJ_COFF_OMIT_OPTIONAL_HEADER.
	(crawl_symbols): Handle 8 character section name correctly.  Use
	H_{SET,GET}_* macros.
	(do_linenos_for): Set lineno size in object_headers.
	(write_object_file): Use H_{SET,GET}_* macros.  Don't bother to
	set s_vaddr here.  If string_byte_count remains 4, set it back to
	0, and only write strings out if there are some.  Call
	fill_section before do_relocs_for and do_linenos_for.
	(obj_coff_section): Handle optional quoted second argument giving
	section characteristics.
	(obj_coff_bss): Added to handle .bss.
	(obj_coff_ident): Added to handle .ident (puts string in .comment
	section).
	(obj_coff_lcomm): Put common symbols in .bss, not .data.
	(fixup_mdeps): Change to segment.  Call frag_wane after
	md_convert_frag.
	(fixup_segment): Explicitly check S_IS_COMMON before making 386
	adjustment (already happened only for common symbols, but this is
	clearer).
	* config/obj-coffbfd.h (OBJ_COFF_OMIT_OPTIONAL_HEADER): Define.
	* config/tc-i386.c (s_bss): Don't use if I386COFF.
	(md_pseudo_table): Ignore .optim and .noopt.
	(tc_coff_sizemachdep): New function.
	* config/tc-i386.h (REVERSE_SORT_RELOCS): Undef, for SVR3
	compatibility.
	(LOCAL_LABEL): Removed definition.
	(DOT_LABEL_PREFIX): Defined.
1992-12-30 20:34:14 +00:00
Ian Lance Taylor
3eb802b53a Wed Dec 16 12:12:33 1992 Ian Lance Taylor (ian@cygnus.com)
* write.c, obj-ieee.c: don't define SUB_SEGMENT_ALIGN if it is
	already defined.
1992-12-16 20:13:53 +00:00
Ken Raeburn
7f2cb2702a Some cleanup.
Deleted some unused code.
Fixed some declarations to use PARAMS macro.
Fixed up configure.in for new targets.
Some whitespace/comment fixes.
Merged config/ChangeLog.
1992-12-03 23:54:54 +00:00
Ken Raeburn
6efd877de5 Ran "indent", for GNU coding style; some code & comments still need fixup.
Removed some unneeded files.

configure.in: Don't look for te-386bsd.h, which doesn't exist...
1992-11-23 20:39:57 +00:00
Ian Lance Taylor
987b14913a Sun Sep 13 20:30:10 1992 Ian Lance Taylor (ian@cygnus.com)
* write.c (fixup_segment): fixed missing parens in expression
	checking for byte or word overflow.
1992-09-14 03:34:19 +00:00
Ken Raeburn
09952cd955 mainly link-relax changes 1992-08-19 14:42:21 +00:00
Steve Chamberlain
65bfcf2e61 * subsegs.c (subsegs_begin): create bss0_frchainP in the same was
as data0_frchainP

	* write.c (write_object_file): various changes to handle data in
	the BSS segment in much the same was as stuff in the DATA segment.

	* subsegs.c (subseg_change): allow and handle a change into SEG_BSS.
1992-06-09 19:36:49 +00:00
Steve Chamberlain
f8701a3ff8 Thu Jun 4 11:59:13 1992 Steve Chamberlain (sac@thepub.cygnus.com)
* expr.c(expr): allow SEG_REGISTER in expressions.
	* read.c(pseudo_set): register expressions can be the source of a
	set.
	* subsegs.c (subseg_new): Now -R forces all changes to SEG_DATA to
	goto SEG_TEXT (if a.out)
	* write.c (write_object_file): If a.out don't use the old way for
	-R.
	* config/obj-a.out (s_sect): complain if the user tries to use a
	subsegment with a value which might interfere with out -R hackery.
	* config/tc-m68k.c (m68k_reg_parse): lookup names in symbol table
	rather than use ugly if tree. (init_regtable): insert register
	names into symbol table.
1992-06-04 19:21:58 +00:00
Michael Tiemann
ebfb416750 Fix -R problem from Adobe 1992-06-02 23:49:59 +00:00
Sean Eric Fagan
343fb08da8 Change a series of #if/#elif to #if/#else/#if.../#endif. The apollo
compiler lies about being ANSI conformant.
1992-04-07 22:18:18 +00:00
Michael Tiemann
961815e432 Make the declarations of fix_new consistent under __STDC__. It might
be better to #define NEED_FX_R_TYPE in TC_A29K and TC_SPARC instead of
having this complicated conditional, but that's not my call.
1992-03-01 12:45:17 +00:00
Steve Chamberlain
c593cf412b * app.c: MRI compatibility - allow single quote to start a string.
* as.c: fix typo recently introduced.
	* as.h : Don't include aout/reloc.h - it's not right for COFF!
	* expr.c: Much rewriting, to accomodate MRI syntax for
	expressions. Also easier to read now.
	* listing.c: Put back defuns
	* read.c: modified to accept MRI syntax, put back listing pseudo
	ops so that an assembler built with NO_LISTING ignores list ops
	rather than pukes.
	* write.c, write.h: fixs - only keep a reloc type in a fix if the target
	machine is a SPARC or a 29K.
	* config/obj-aout.c: added s_sect pseudo op
	* config/obj-coffbfd.c: lints, set the filehdr flags right and
	fill in the timestamp.
	* config/obj-coffbfd.h: Since we don't include aout/reloc.h
	anymore, define all the relocs which the tc-<x> bit will use so we
	can translate from them to the coff types.
	* config/tc-a29k.c: reloc_type isn't ane enum any more
	* config/tc-m68k.c: Added NO_RELOC definition.

Now compiles for sparc aout, 68k aout (MRI and MIT syntax),
29k coff.

So far works as replacement for sparc and 68k /bin/as.
1992-02-22 20:45:24 +00:00
K. Richard Pixley
6d5460ab89 changes from Minh Tran-Le <TRANLE@INTELLICORP.COM> to support i386
coff as it appears to be used on aix386.
1992-02-21 11:04:51 +00:00
K. Richard Pixley
542e1629fd fighting bitrot in a major way 1992-02-17 15:54:49 +00:00
K. Richard Pixley
3340f7e5fd White space and comment changes. #ifdef __STDC__ becomes #if __STDC__
== 1.  Get the declarations right in listing.[hc].
1992-02-15 21:13:03 +00:00
K. Richard Pixley
a39116f1c9 White space and comments only. The devo tree prior to this delta is
tagged as "vanilla" for your convenience.

There are also some comment changes.
1992-02-13 08:33:54 +00:00
John Gilmore
4543283685 * as.h: Move redefine of xfree.
* read.c:  Use xmalloc, not malloc.
* expr.c, input-scrub.c, write.c:  Avoid "know" macros
that cover more than one line, since this causes char strings
with embedded newlines.
1992-01-05 00:40:29 +00:00
K. Richard Pixley
f6e504fe91 Polishing m68k support. 1991-07-27 02:34:20 +00:00
K. Richard Pixley
fecd2382e7 Initial revision 1991-04-04 18:19:53 +00:00