From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Lipe To: gas2@cygnus.com Subject: gas fixes for x86 elf/coff emulations Date: Wed, 08 Jan 1997 22:04:00 -0000 Message-id: X-SW-Source: 1997/msg00006.html As promised, here's the additional work in config/tc-i386.c. I have now built binutils with gcc and the assembler with yesterday's patches plus this work. Problems remain with debugging (-gstabs aborts in COFF, COFF debugging gets tripped up by certain files) but in loose generalities, things work. Things seem to work quite well in ELF. I don't know at this time how much of the problems I'm seeing are artifacts of of the questionable (?) --iwth-bfd-assembler version of the COFF stuff. Whitespace may need to be adjusted. RJL Wed Jan 8 23:28:34 CST 1997 Robert Lipe * config/tc-i386.c: Several changes to allow emulations to work for x86 ELF and COFF. *** gas.orig/config/tc-i386.c Tue Dec 17 03:05:30 1996 --- gas/config/tc-i386.c Wed Jan 8 23:08:22 1997 *************** *** 104,110 **** /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful */ ! #if defined (TE_I386AIX) || defined (OBJ_ELF) const char comment_chars[] = "#/"; #else const char comment_chars[] = "#"; --- 104,110 ---- /* This array holds the chars that always start a comment. If the pre-processor is disabled, these aren't very useful */ ! #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) const char comment_chars[] = "#/"; #else const char comment_chars[] = "#"; *************** *** 118,124 **** #NO_APP at the beginning of its output. */ /* Also note that comments started like this one will always work if '/' isn't otherwise defined. */ ! #if defined (TE_I386AIX) || defined (OBJ_ELF) const char line_comment_chars[] = ""; #else const char line_comment_chars[] = "/"; --- 118,124 ---- #NO_APP at the beginning of its output. */ /* Also note that comments started like this one will always work if '/' isn't otherwise defined. */ ! #if defined (TE_I386AIX) || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) const char line_comment_chars[] = ""; #else const char line_comment_chars[] = "/"; *************** *** 555,564 **** operand_chars[(unsigned char) *p] = *p; } ! #ifdef OBJ_ELF record_alignment (text_section, 2); record_alignment (data_section, 2); record_alignment (bss_section, 2); #endif } --- 555,566 ---- operand_chars[(unsigned char) *p] = *p; } ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ! if (OUTPUT_FLAVOR == bfd_target_elf_flavour) { record_alignment (text_section, 2); record_alignment (data_section, 2); record_alignment (bss_section, 2); + } #endif } *************** *** 2631,2640 **** if (fixP->fx_r_type == BFD_RELOC_32_PCREL && fixP->fx_addsy) { #ifndef OBJ_AOUT value += fixP->fx_where + fixP->fx_frag->fr_address; #endif ! #ifdef OBJ_ELF ! if (S_GET_SEGMENT (fixP->fx_addsy) == seg || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) { /* Yes, we add the values in twice. This is because --- 2633,2644 ---- if (fixP->fx_r_type == BFD_RELOC_32_PCREL && fixP->fx_addsy) { #ifndef OBJ_AOUT + if (OUTPUT_FLAVOR == bfd_target_elf_flavour) value += fixP->fx_where + fixP->fx_frag->fr_address; #endif ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ! if (OUTPUT_FLAVOR == bfd_target_elf_flavour) ! if (S_GET_SEGMENT (fixP->fx_addsy) == seg || (fixP->fx_addsy->bsym->flags & BSF_SECTION_SYM) != 0) { /* Yes, we add the values in twice. This is because *************** *** 2648,2655 **** /* Fix a few things - the dynamic linker expects certain values here, and we must not dissappoint it. */ ! #ifdef OBJ_ELF ! if (fixP->fx_addsy) switch(fixP->fx_r_type) { case BFD_RELOC_386_PLT32: /* Make the jump instruction point to the address of the operand. At --- 2652,2660 ---- /* Fix a few things - the dynamic linker expects certain values here, and we must not dissappoint it. */ ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ! if ( (OUTPUT_FLAVOR == bfd_target_elf_flavour) && ! fixP->fx_addsy) switch(fixP->fx_r_type) { case BFD_RELOC_386_PLT32: /* Make the jump instruction point to the address of the operand. At *************** *** 2838,2856 **** flag_do_long_jump = 1; break; ! #ifdef OBJ_ELF /* -k: Ignore for FreeBSD compatibility. */ case 'k': break; /* -V: SVR4 argument to print version ID. */ case 'V': ! print_version_id (); break; /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section should be emitted or not. FIXME: Not implemented. */ case 'Q': break; #endif --- 2843,2866 ---- flag_do_long_jump = 1; break; ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) /* -k: Ignore for FreeBSD compatibility. */ case 'k': + if (OUTPUT_FLAVOR == bfd_target_elf_flavour) return 1 ; break; /* -V: SVR4 argument to print version ID. */ case 'V': ! if (OUTPUT_FLAVOR == bfd_target_elf_flavour) ! print_version_id (); ! else ! return 0 ; break; /* -Qy, -Qn: SVR4 arguments controlling whether a .comment section should be emitted or not. FIXME: Not implemented. */ case 'Q': + if (OUTPUT_FLAVOR == bfd_target_elf_flavour) return 1 ; break; #endif *************** *** 3003,3008 **** --- 3013,3031 ---- return rel; } + const char * + i386_target_format() + { + switch (OUTPUT_FLAVOR) { + case bfd_target_coff_flavour: + return "coff-i386" ; + case bfd_target_elf_flavour: + return "elf32-i386" ; + default: + abort() ; + } + } + #else /* ! BFD_ASSEMBLER */ #if (defined(OBJ_AOUT) | defined(OBJ_BOUT))