GNU tool set

Source: Internet
Author: User
GNU assembler (gas)

GNU assembler (called gas) is the most popular assembler in UNIX environments.

Unlike most other development software packages, the GNU assembler is not released in a separate package. It is bundled with other development software in the GNU binutils package. The binutils package contains the following programs:

Addr2line converts an address to a file name and a row number.

Create, modify, and expand an AR File Archive

As assemble the assembly language code into the target code

Filter for C ++ filt to restore the C ++ symbol

Program for GPROF to display program profile information

LD converts the target code file to an executable file connector.

Nlmconv converts the target code to the NetWare loadable module format

NM list symbols in the target file

Copy and translate the target file

Objdump displays messages from the target file

Ranlib generates the index of the archive file content

Readelf displays messages from the target file in the ELF format

Size: list the segment lengths of the target or archive files.

Strings: Display printable strings in the target file

Strip discard symbol

Windres compiles Microsoft Windows resource files

1. gas usage

As [-A [cdhlns] [= file] [-D] [-- defsym sym = Val]

[-F] [-- ststabs] [-- ststabs +] [-- gdwarf2] [-- help]

[-I dir] [-J] [-K] [-L]

[-- Listing-LHS-width = num] [-- listing-lhs-width2 = num]

[-- Listing-RHS-width = num] [-- listing-cont-lines = num]

[-- Keep-locals] [-O objfile] [-R] [-- Statistics] [-v]

[-Version] [-- version] [-W] [-- Warn] [-- fatal-warnings]

[-W] [-x] [-Z] [-- target-help] [target-options]

[-- | Files...]

Ii. Parameter Details

-A: Specifies the list contained in the output.

-D contains it for backward compatibility, but is ignored

-- Defsym defines symbols and values before compiling source code

-F quick assembly, skip comments and blank spaces

-- Gstabs contains debugging information for each line of source code.

-- Gstabs + contains special GDB debugging information

-I: searches for directories containing files.

-J: Do not warn of signed Overflow

-K contains it for backward compatibility, but is ignored

-L save the local symbol in the symbol table

-- Listing-LHS-width: set the maximum width of the output data column.

-- Listing-lhs-width2 sets the maximum width of the output data column of a row

-- Listing-RHS-width: set the maximum width of the Input Source code line.

-- Listing-cont-lines: sets the maximum number of lines output by a single input row in the list.

-O specifies the name of the output target file

-R combines data segments into text segments

-- Statistics: displays the maximum amount of hull time used by the Assembly.

-V: displays the as version number.

-W: no warning information is displayed.

-- Use standard input for source files

 

 

GNU connector (LD)

The GNU connector LD is used to link the target code file to an executable file or library file .. The link mainly involves four aspects: storage allocation, symbol management, libraries, and relocation.

LD can identify a linker scriopt file in linker command language to explicitly control the link process. Using the BFD (binary format description) library, LD can read and operate target files in various formats, such as coff (Common Object File Format), ELF (executable and linking format), and A. Out.

1. LD Command Format

The LD command format is as follows:

LD [-O output] objfile...

[-Aarchitecture] [-B input-format] [-bstatic]

[-Bdynamic] [-bsymbolic] [-C commandfile] [-- CREF]

[-D |-DC |-DP]

[-Defsym symbol = expression] [-- demangle]

[-- No-demangle] [-e entry] [-embedded-relocs] [-E]

[-Export-dynamic] [-F name] [-- auxiliary name]

[-F name] [-- Filter Name] [-format input-format]

[-G] [-G size] [-H Name] [-soname name] [-- help]

[-I] [-lar] [-lsearchdir] [-M] [-map mapfile]

[-M emulation] [-N |-N] [-noinhibit-exec]

[-No-keep-memory] [-no-Warn-Mismatch] [-0 level]

[-Oformat output-format] [-r filename] [-Relax]

[-R |-Ur] [-rpath Directory] [-rpath-link Directory]

[-S] [-S] [-shared] [-sort-common]

[-Split-by-reloc count] [-Split-by-file]

[-T commandfile]

[-- Section-start sectionname = sectionorg]

[-Ttext textorg] [-tdata dataorg] [-tbss bssorg]

[-T] [-u sym] [-V] [-V] [-- verbose] [-- version]

[-Warn-common] [-Warn-constructors]

[-Warn-multiple-GP] [-Warn-Once]

[-Warn-section-align] [-- whole-Archive]

[-- No-whole-Archive] [-- wrap symbol] [-x] [-x]

 

2. Parameter Details

-B: Specify the format of the target code input file.

-Bstatic: only use static databases

-Bdynamic only uses the dynamic library

-Bsymbolic binds the reference to the global symbol in the shared library.

-C: Read the command from the specified command file

-CREF: create a cross-reference table

-D. Set spaces for common symbols, even if the output can be relocated.

-Defsym creates the specified global symbol in the output file.

-- Demangle restores the symbol name in the error message

-E use the specified symbol as the execution point of the program's cook.

-E for elf files, add all the symbols to the dynamic symbol table

-F: for shared objects in ELF format, set the dt_auxiliary name.

-F: for shared objects in ELF format, dt_tilter name

-Format: Specify the format of the target code input file (same as-B)

-G is ignored. Used to provide compatibility with other tools

-H: for shared objects in ELF format, set the dt_soname name.

-I: Execute incremental connections.

-L add the specified archive file to the file list to be connected

-L add the specified path to the library directory list

-M: display the connection ing for diagnostic purposes.

-Map creates a specified file to include the connection ing.

-M simulate the specified Connector

-N: read/write text and data segments

-N: Set the text segment to read-only.

-Noinhibit-Exec: generate the output file even if a non-fatal connection error occurs.

-No-keep-memory: memory usage optimization connection

-No-Warn-Mismatch: allows an unmatched target file to be connected.

-O: Generate optimized output files

-O specifies the name of the output file

-Oformat: Specify the binary format of the output file.

-R: reads the symbol name and address from the specified file.

-R generates relocated output (called partial join)

-Rpath: add the specified directory to the Runtime library search path.

-Rpath-link: Specifies the directory for searching the shared library at runtime.

-S: Ignore the debugger symbol information from the output file

-S ignores all symbolic information from the output file

-Shared Library Creation

-Sort-common: symbols are not sorted by length in the output file.

-Split-by-reloc: create additional segments in the output file according to the specified length

-Split-by-file: create additional segments for each target file in the output file.

-- Section-start: Specifies the address in the output file to locate the specified segment.

-T specifies the command file (same as-C)

-Ttext uses the specified address as the starting point of the text segment.

-Tdata uses the specified address as the start point of the Data Segment.

-Tbss uses the specified address as the starting point of the BSS segment.

-T display their names when processing input files

-U forces the specified symbol to be used as an undefined symbol in the output file.

-Warn-common: a warning is issued when one universal symbol is combined with another universal symbol.

-Warn-constructors: If no global constructor is used, a warning is issued.

-Warn-once only generates one warning for each undefined symbol

-Warn-section-align: If the output segment address is modified for align, a warning is issued.

-- Whole-archive: contains all files in the specified archive.

-X: delete all local temporary symbols.

-X: delete all local symbols.

3. Common options

-B Target: Set the file format of the target file
-E address: Set the start address of the target file.
-EB: Link to the target file of big-Endian.
-El: link the target small-Endian File
-L libname: the Library file to be linked when the execution program is created (for example, if a library is test, it can be-ltest)
-L Directory: Path of the file to be searched when searching for the library file to be linked
-O file: Set the name of the output file.
-S removes all Symbol Information in the output file
-S removes debugging symbol information from the output file
-T file: Read the link description script to determine the location address of the symbols.
-V: Output LD version information
-X removes all local Symbol Information
-X removes temporary local symbol information. This option is set by default.
-The output file created by bstatic is linked to the static Link Library.
-The output file link created by bdynamic is a dynamic link library.
-Tbss address: Set the start address of section BSS.
-Tdata address: Set the start address of section data.
-Ttext address: Set the start address of section text.

 

 

GNU Compiler (GCC)

GCC can compile many different advanced languages. Including C, C ++, objective-C, Fortran, Java, and Ada.

I. GCC Command Format

The command line format of GCC is as follows:

GCC [-c |-S |-E] [-STD = standard]

[-G] [-PG] [-olevel]

[-Wwarn...] [-pedantic]

[-Idir...] [-ldir...]

[-Dmacro [= defn]...] [-umacro]

[-Foption...] [-mmachine-option...]

[-O outfile] infile...

 

Ii. Parameter Details

-C compilation or assembly code without connection

-S: stops compilation, but does not compile

-E: stops preprocessing, but does not compile.

-O specifies the output file name to be used

-V shows the commands used in each compilation phase

-The language standard specified by STD

-G generate debugging information

-The extra code to be used to generate GPROF files by PG

-O optimized executable code

-W: Set the compiler warning message level

-The mandatory diagnosis list is released for pedantic according to the C standard.

-I: Specifies the directory containing files.

-L specify the directory of the Library File

-D macro used in pre-defined source code

-U cancels any defined macros

-F specifies the options used to control compiler Behavior

-M: Specifies hardware-related options.

 

GNU Debugger (GDB) I. GDB command line format

GDB command line format:

GDB [-NX] [-q] [-Batch] [-Cd = dir] [-F] [-B BPS] [-tty = Dev]

[-S symfile] [-e prog] [-se prog] [-C Core] [-x cmds] [-D dir]

[Prog [core | procid]

Ii. Details about GDB Parameters

-B. Set the line speed of the serial interface during remote debugging.

-Batch runs in batch mode

-C: Specify the core dump file to be analyzed

-CD: Specify the working directory

-D: Specify the directory for searching the source file

-E: Specifies the file to be executed.

-Output the file name and row number in the standard format during the fcall.

-NX does not execute commands from the. gdbinit File

-Q quiet mode-No output

-S specifies the file name of the symbol

-Se: Specifies the file name of the symbol and drug execution.

-TTY: Set standard input and output devices

-X: Execute the gdb command from the specified file

Iii. gdb commands

The GDB command is as follows:

Break sets a breakpoint in the source code to stop execution.

Watch sets the monitoring point and stops running when the variable reaches a specific value.

Info: Observe system elements, such as registers, stacks, and memory.

X check memory location

Print DISPLAY variable value

Run starts program execution in the debugger

List to list specified functions or rows

Next execute the next instruction in the program

Step: Execute the next instruction in the program.

Cont continues executing the program from the stopped position

Until runs the program until it reaches the specified source code line (or larger)

 

 

GNU objdump Program

Programmers can use the objdump program to view the script code generated by the compiler in the target code file. This program not only displays the assembly language code, but also displays the generated original script code.

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.