The Open Source Swiss Army Knife

/unix/commandline/
/unix/commandline/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /unix   /commandline 
Permalink: nm.htm
Title: add
article options : please login   |  print view

The nm(1) command can report the list of symbols in a given library. For a given library nm(1) can list the symbol names defined, each symbol's value, and the symbol's type. It can also identify where the symbol was defined in the source code (by filename and line number), if that information is available in the library (see the -l option). source: http://www.cgsecurity.org/Articles/1-MISC/Protections-1/

Avec gcc, nous transformons ces instructions en fichier objet, puis la commande nm en affiche le contenu :

  $ gcc -c hello.c -o hello.o
  $ ls
  hello.c  hello.o
  $ nm hello.o
  00000004 C empty
  00000000 t gcc2_compiled.
  00000000 T main
           U printf
  00000000 D world

La commande nm affiche tous les symboles contenus dans un fichier objet. Pour chaque symbole, nm donne :

  • la valeur du symbole ;
  • son type (en minuscule, le symbole est local, en majuscule, il est global) :
    • B : le symbole se trouve dans la zone mémoire .bss ; UNINITIALIZED DATA SEGMENT
    • D : le symbole se situe dans la zone mémoire des données initialisées .data ;INITIALIZED DATA SECTION
    • C : ce flag sert pour les symboles qui ne sont pas initialises apres la compilation. Dans notre exemple, empty est defini mais pas encore initialise. DEFINED BUT NOT INITIALIZED. S'il ne l'est nulle part, son type changera alors en B ;
    • T : le symbole est dans la zone memoire .text (code) ; NORMAL DEFINITION IN THE CODE SECTION
    • U : le symbole est indefini (undefined).
    • Il existe de nombreux autres types décrits dans la page info nm ;

  • le nom du symbole.

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top