From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 45E4B3858D38; Fri, 17 Nov 2023 10:21:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45E4B3858D38 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: conditionally hide object-format-specific functions X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: d9a1b71137d206f1ff73eee25423cf6d22814495 X-Git-Newrev: 071c5d81c7681fd92189c380e14266054f0c6c41 Message-Id: <20231117102136.45E4B3858D38@sourceware.org> Date: Fri, 17 Nov 2023 10:21:36 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2023 10:21:36 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D071c5d81c768= 1fd92189c380e14266054f0c6c41 commit 071c5d81c7681fd92189c380e14266054f0c6c41 Author: Jan Beulich Date: Fri Nov 17 11:20:49 2023 +0100 x86: conditionally hide object-format-specific functions =20 ELF-only functions don't need to be built when dealing with a non-ELF target. md_section_align() also doesn't need to be a function when dealing with non-AOUT targets. Similarly tc_fix_adjustable() can be a simple macro when building non-ELF targets. =20 Furthermore x86_elf_abi is already used in ELF-only code sections, with one exception. By adjusting that, the otherwise bogusly named variable can also be confined to just ELF builds. Diff: --- gas/config/tc-i386.c | 46 +++++++++++++++++++++++----------------------- gas/config/tc-i386.h | 8 ++++++++ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 8d11955a88b..1076d51bc7d 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -587,9 +587,7 @@ static int use_rela_relocations =3D 0; /* __tls_get_addr/___tls_get_addr symbol for TLS. */ static const char *tls_get_addr; =20 -#if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \ - || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \ - || defined (TE_PE) || defined (TE_PEP) || defined (OBJ_MACH_O)) +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) =20 /* The ELF ABI to use. */ enum x86_elf_abi @@ -3527,15 +3525,15 @@ reloc (unsigned int size, return NO_RELOC; } =20 +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) /* Here we decide which fixups can be adjusted to make them relative to the beginning of the section instead of the symbol. Basically we need to make sure that the dynamic relocations are done correctly, so in some cases we force the original symbol to be used. */ =20 int -tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED) +tc_i386_fix_adjustable (fixS *fixP) { -#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) if (!IS_ELF) return 1; =20 @@ -3586,9 +3584,9 @@ tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED) || fixP->fx_r_type =3D=3D BFD_RELOC_VTABLE_INHERIT || fixP->fx_r_type =3D=3D BFD_RELOC_VTABLE_ENTRY) return 0; -#endif return 1; } +#endif =20 static INLINE bool want_disp32 (const insn_template *t) @@ -15264,10 +15262,12 @@ i386_target_format (void) if (startswith (default_arch, "x86_64")) { update_code_flag (CODE_64BIT, 1); +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) if (default_arch[6] =3D=3D '\0') x86_elf_abi =3D X86_64_ABI; else x86_elf_abi =3D X86_64_X32_ABI; +#endif } else if (!strcmp (default_arch, "i386")) update_code_flag (CODE_32BIT, 1); @@ -15399,12 +15399,12 @@ md_undefined_symbol (char *name) return 0; } =20 +#if defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) /* Round up a section size to the appropriate boundary. */ =20 valueT -md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) +md_section_align (segT segment, valueT size) { -#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT)) if (OUTPUT_FLAVOR =3D=3D bfd_target_aout_flavour) { /* For a.out, force the section size to be aligned. If we don't do @@ -15417,10 +15417,10 @@ md_section_align (segT segment ATTRIBUTE_UNUSED, = valueT size) align =3D bfd_section_alignment (segment); size =3D ((size + (1 << align) - 1) & (-((valueT) 1 << align))); } -#endif =20 return size; } +#endif =20 /* On the i386, PC-relative offsets are relative to the start of the next instruction. That is, the address of the offset, plus its @@ -15864,6 +15864,20 @@ x86_dwarf2_addr_size (void) return bfd_arch_bits_per_address (stdoutput) / 8; } =20 +#ifdef TE_PE +void +tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size) +{ + expressionS exp; + + exp.X_op =3D O_secrel; + exp.X_add_symbol =3D symbol; + exp.X_add_number =3D 0; + emit_expr (&exp, size); +} +#endif + +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) int i386_elf_section_type (const char *str, size_t len) { @@ -15884,20 +15898,6 @@ i386_solaris_fix_up_eh_frame (segT sec) } #endif =20 -#ifdef TE_PE -void -tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size) -{ - expressionS exp; - - exp.X_op =3D O_secrel; - exp.X_add_symbol =3D symbol; - exp.X_add_number =3D 0; - emit_expr (&exp, size); -} -#endif - -#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) /* For ELF on x86-64, add support for SHF_X86_64_LARGE. */ =20 bfd_vma diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index a3d463d961f..31f2f015c74 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -141,8 +141,12 @@ int i386_validate_fix (struct fix *); if (!i386_validate_fix(FIX)) goto SKIP; \ } while (0) =20 +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) #define tc_fix_adjustable(X) tc_i386_fix_adjustable(X) extern int tc_i386_fix_adjustable (struct fix *); +#else +#define tc_fix_adjustable(X) ((void)(X), 1) +#endif =20 /* Values passed to md_apply_fix don't include the symbol value. */ #define MD_APPLY_SYM_VALUE(FIX) 0 @@ -219,6 +223,10 @@ if ((n) \ extern void i386_cons_align (int); #define md_cons_align(nbytes) i386_cons_align (nbytes) =20 +#if !defined (OBJ_AOUT) && !defined (OBJ_MAYBE_AOUT) +#define md_section_align(seg, value) ((void)(seg), (value)) +#endif + void i386_print_statistics (FILE *); #define tc_print_statistics i386_print_statistics