Skip to content

Commit

Permalink
MIPS/Gas: Support .L/$ as the mark of local symbol
Browse files Browse the repository at this point in the history
In as.texi, there are lines:
  A local symbol is any symbol beginning with certain local
  label prefixes. By default, the local label prefix is
  @samp{.L} for ELF systems or @samp{L} for traditional a.out
  systems, but each target may have its own set of local
  label prefixes.

Let's support it for MIPS:
1) For OldABI, GCC uses "$" to mark local symbols, and
   for NewABI, ".L" is used. So let's support both for
   OldABI, and ".L" only for NewABI.
2) Emit an fatal error, if a local symbol is used, while
   not defined, just like LLVM does.
  • Loading branch information
wzssyqa authored and ouuleilei-bot committed Feb 5, 2024
1 parent 324998b commit 8b03d9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gas/config/tc-mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -17724,6 +17724,16 @@ pic_need_relax (symbolS *sym)
if (symbol_section_p (sym))
return true;

if (strstr (S_GET_NAME (sym), ".L") == S_GET_NAME (sym)
|| ((mips_abi == O64_ABI || mips_abi == O32_ABI)
&& strstr (S_GET_NAME (sym), "$") == S_GET_NAME (sym)))
{
if (!S_IS_DEFINED (sym))
as_fatal (_("undefined temporary symbol: %s"),
S_GET_NAME (sym));
return true;
}

symsec = S_GET_SEGMENT (sym);

/* This must duplicate the test in adjust_reloc_syms. */
Expand Down

0 comments on commit 8b03d9a

Please sign in to comment.