Gas/ELF: warn upon non-default visibility of local symbols
The assembler now warns when a local symbol is defined with non-default visibility, preventing the creation of invalid ELF files.
The assembler (gas) now issues a warning when a local symbol is defined with non-default visibility (e.g., PROTECTED or HIDDEN). The ELF standard forbids local symbols from having such visibility attributes, and silently creating such symbols can lead to issues with other tools. This change helps developers catch these errors early. A LoongArch-specific hook was also removed in response.
In Details
The ELF specification prohibits STB_LOCAL symbols from having non-default visibility (STV_PROTECTED, STV_HIDDEN, or STV_INTERNAL). This commit modifies gas/config/obj-elf.c to issue a warning when such symbols are encountered in ELF assembly. The LoongArch tc_symbol_new_hook() is removed as it's no longer needed. This change prevents the creation of invalid ELF files and primarily affects developers working with assembly code and ELF symbol visibility.
For Context
The GNU Assembler (gas) translates assembly code into object code. Object code uses the ELF standard, which defines how symbols (names for memory locations) are handled. Symbols can be local (only visible within the current object file) or global (visible to other object files). This commit enforces a rule in the ELF standard: local symbols should not have special visibility attributes like "hidden" or "protected". The assembler will now warn if you try to create a local symbol with such attributes, as this can lead to problems when linking the object files together. This helps ensure that the generated object files are valid and compatible.