Skip to content

Commit

Permalink
Drop the leading underscore for external symbols
Browse files Browse the repository at this point in the history
Standard ELF targets don't use leading underscore.
  • Loading branch information
vinriviere committed Sep 10, 2023
1 parent 99cc418 commit 75c6b96
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
4 changes: 1 addition & 3 deletions bfd/config.bfd
Original file line number Diff line number Diff line change
Expand Up @@ -840,12 +840,10 @@ case "${targ}" in
targ_selvecs="m68hc11_elf32_vec m68hc12_elf32_vec"
;;

m68k-atari-mintelf)
m68k-*-mintelf)
targ_defvec=m68k_elf32_vec
targ_selvecs="m68k_elf32_vec m68k_elf32_atariprg_vec"
targ_underscore=yes
;;

m68*-*-*)
targ_defvec=m68k_elf32_vec
;;
Expand Down
4 changes: 2 additions & 2 deletions bfd/elf32-atariprg.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ m68k_elf32_atariprg_final_link (bfd *abfd, struct bfd_link_info *info)
TRACE ("m68k_elf32_atariprg_final_link END %s %s\n", abfd->xvec->name, abfd->filename);

/* Remember the address of the stack size variable. */
h = (struct elf_link_hash_entry *) bfd_hash_lookup (&info->hash->table, "__stksize", false, false);
h = (struct elf_link_hash_entry *) bfd_hash_lookup (&info->hash->table, "_stksize", false, false);
if (h != NULL)
{
asection *input_sec;
Expand Down Expand Up @@ -685,7 +685,7 @@ write_prgelf_header (bfd *abfd)

if (myinfo->stkpos == 0)
{
_bfd_error_handler ("%pB: unable to determine the __stksize position",
_bfd_error_handler ("%pB: unable to determine the _stksize position",
abfd);
bfd_set_error (bfd_error_invalid_operation);
return false;
Expand Down
4 changes: 2 additions & 2 deletions ld/emultempl/m68kmintelf.em
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ m68kmintelf_before_parse (void)
/* Then add our own linker initialization here. */

/* Standard default entry point is the "start" symbol. But the MiNTLib entry
point is named "__start". We could change the default here, but that would
point is named "_start". We could change the default here, but that would
be very non-standard. Instead, I prefer to add a custom ENTRY() in the
linker script. */
/*lang_default_entry ("__start");*/
/*lang_default_entry ("_start");*/
}

/* This method is called after assigning values from the script. */
Expand Down
26 changes: 12 additions & 14 deletions ld/scripttempl/m68kmintelf.sc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cat <<EOF
notice and this notice are preserved. */

OUTPUT_FORMAT("${OUTPUT_FORMAT}")
ENTRY(__start) /* The MiNTLib uses this entry symbol, so we do. */
ENTRY(_start) /* The MiNTLib uses this entry symbol, so we do. */

/* ELF Program Headers are mapped to GEMDOS process segments. */
PHDRS
Expand Down Expand Up @@ -43,7 +43,7 @@ SECTIONS
/* Program code. */
.text :
{
PROVIDE(__start = .); /* Default entry point if __start isn't defined. */
PROVIDE(_start = .); /* Default entry point if _start isn't defined. */
*crt0.o(.text .text.*)
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
Expand All @@ -56,33 +56,33 @@ SECTIONS
} :TEXT =0x4afc /* Pad with ILLEGAL instruction */

/* End of .text section. */
__etext = .;
PROVIDE(_etext = .);
_etext = .;
PROVIDE(etext = .);

/* Preinitializers array. */
.preinit_array (READONLY) :
{
PROVIDE_HIDDEN (___preinit_array_start = .);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (___preinit_array_end = .);
PROVIDE_HIDDEN (__preinit_array_end = .);
}

/* Initializers array. */
.init_array (READONLY) :
{
PROVIDE_HIDDEN (___init_array_start = .);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (___init_array_end = .);
PROVIDE_HIDDEN (__init_array_end = .);
}

/* Finalizers array. */
.fini_array (READONLY) :
{
PROVIDE_HIDDEN (___fini_array_start = .);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (___fini_array_end = .);
PROVIDE_HIDDEN (__fini_array_end = .);
}

/* Global Constructors. */
Expand Down Expand Up @@ -140,8 +140,7 @@ SECTIONS
} :DATA

/* End of .data section. */
__edata = .;
PROVIDE(_edata = .);
_edata = .;

/* Exception handling. */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
Expand All @@ -160,8 +159,7 @@ SECTIONS
} :BSS

/* End of .bss section */
__end = .;
PROVIDE(_end = .);
_end = .;

/*** Extra sections not loaded by the operating system **********************/

Expand Down

0 comments on commit 75c6b96

Please sign in to comment.