[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] MiNTlib assembly labels naming?



Hi,

On sunnuntai 07 huhtikuu 2013, Andreas Schwab wrote:
> Eero Tamminen <oak@helsinkinet.fi> writes:
> > Could that and similar non-function ASM labels be made local,
> 
> Labels not declared global are local.  If you want them left out
> of the symbol table, then their name needs to start with L.

Thanks!

When looking at symbols which occur several times in MiNTlib,
"exit" is found from 3 different places:
----------
$ nm /usr/lib/libc.a | grep -e "\.o" -e exit | grep -B1 ' exit$'
bcopy.o:
000000c2 t exit
--
bzero.o:
000000a2 t exit
--
memset.o:
000000a4 t exit
----------

All of them were included also into binary I was debugging:
----------
$ nm cgdb/cgdb | grep ' exit$'
0005549c t exit
00056472 t exit
0005e4ce t exit
----------

Gdb (Vincent's v5.1 build) didn't give any warning about there being
multiple "exit" addresses when I set the breakpoint.  Which of
the addresses Gdb selects when symbol has multiple addresses?


There seem to be also some symbols that occur in even more places,
see [1].  The most common of them is this:
----------
$ nm /usr/lib/libc.a | grep -e "\.o" -e _buffer | grep -B1 ' _buffer$'
getutent.o:
00000028 b _buffer
--
getutid.o:
00000030 b _buffer
--
getutline.o:
00000030 b _buffer
--
fgetpwent.o:
00000064 b _buffer
--
getpwent.o:
00000060 b _buffer
--
getspent.o:
00000060 b _buffer
----------


There are also some symbols that are prefixed with ".":
----------
$ nm /usr/lib/libc.a | grep " [a-zA-Z] [.][^L]"
00000002 t .printexit
0000004c t .error
00000052 t .get_with_ssystem
0000002a t .nextcookie
00000042 t .restore
00000038 t .return
00000046 t .get_usermode
00000032 t .get_with_ssystem
00000028 t .return
----------
?

They're in:
----------
$ grep -l '^\.[^L]' $(find mintlib/ -name '*.S')
mintlib/startup/crt0.S
mintlib/modf.S
mintlib/mintlib/getcookie.S
mintlib/mintlib/getsysvar.S
mintlib/checkcpu.S
----------

Isn't "." what was used with Devpac for getting a local symbol
i.e. shouldn't '.' be replace with 'L' in those?


> > PS. the symbol not having leading '_' should have been
> > a hint, but I didn't think of that at first (real exit()
> > symbol is of course named "__exit")...
> 
> The C identifier exit is mapped to _exit, not __exit.

In C, yes, but in Gdb it shows up as "__exit"
(as all C symbols get prefixed with '_' by default).


	- Eero

[1] All non-local (Sparemint) MiNTlib symbols that occur more than once:
$ nm /usr/lib/libc.a | grep " [a-zA-Z] [^.]" | cut -d' ' -f3 |\
  sort | uniq -c | grep -v ' 1 ' | sort -nr
      6 _buffer
      4 _passwd
      4 _buf
      3 _tottimeout
      3 _timeout
      3 __tens_in_limb
      3 none
      3 _nbits.2971
      3 ___mpn_lshift_1.clone.0
      3 _line
      3 less4
      3 less256
      3 less2
      3 _initialized
      3 _free_mem
      3 _extensions
      3 exit_d2
      3 exit
      2 ___writev
      2 _writeunix
      2 _writetcp
      2 _wildabbr
      2 _weekday_name
      2 _spwd
      2 set256
      2 set16
      2 _seek
      2 retz
      2 .return
      2 _resbuf.1569
      2 _rendezvous_stat
      2 _rendezvous_request
      2 _readunix
      2 _readtcp
      2 _once.2271
      2 _name.2550
      2 _my_getc
      2 _month_name
      2 _md5_salt_prefix
      2 _makefd_xprt
      2 _lookup.2358
      2 _logname
      2 _isfdtype
      2 _h_errno
      2 _have_Prenice
      2 _have_Pnice
      2 _have_pgrp.3030
      2 .get_with_ssystem
      2 _fillbuf
      2 _errno
      2 _enlarge_buffer
      2 do_set
      2 _buffer_size.1568
      2 _buffer.1567
      2 BIAS8
      2 areeven