In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
As you know, the object file or executable file in Linux consists of multiple segments (such as text segments and data segments). If you want to know the size of each segment, there is a command-line tool-- size. In this tutorial, we will use several easy-to-understand cases to illustrate the basic usage of the tool.
Before we begin, it is important to state that all the cases in this article have been tested in Ubuntu 16.04 LTS.
Linux size command
The size command basically outputs the size of the segments of the specified input file and their sum. Here is the syntax of the command:
Size [- A |-B |-- format=compatibility] [--help] [- d |-o |-x |-- radix=number] [--common] [- t |-- totals] [--target=bfdname] [- V |-- version] [objfile...]
The man page describes it as follows:
GNU's size program lists the segment size of each target file or archive file in the parameter list-as well as the total size. By default, a row of output is generated for each module in each target file or archive library.
Objfile... Is the target file to be checked. If not specified, the default is the file a.out.
Here are some examples of Q & A, hoping to give you some idea of the size command.
Q1. How to use the size command?
The basic usage of size is simple. All you need to do is take the target file / executable file name as input. Here is an example:
Size apl
The output of this command on my system is as follows:
How to use size command
The first three parts are text segments, data segments, and bss segments and their corresponding sizes. Then there is the total size of the decimal and hexadecimal formats. Finally, the file name.
Q2. How to switch between different output formats?
According to the man page, the default output format of size is similar to that of Berkeley. However, you can also use the System V specification if you want. To do this, you can use the-- format option plus the SysV value.
Size apl-format=SysV
Here is its output:
How to switch between different output formats
Q3. How to switch to other units?
By default, the size of the segment is displayed in decimal mode. However, you can also use octal or hexadecimal if you want. The corresponding command line arguments are o and-x, respectively.
How to switch between different size units
With regard to these parameters, the man page says:
-d
-o
-x
-- radix=number
Using these options, you can display the size of each segment in decimal (- d or-- radix 10), octal (- o or-- radix 8), or hexadecimal (- x or-- radix 16) numbers. -- radix number only supports three numeric parameters (8, 10, 16). The total size is given in two bases; decimal and hexadecimal output of-d or-x, or octal and hexadecimal output of-o.
Q4. How do I get the size command to display the total size of all object files?
If you use size to find the segment size of multiple files at once, you can also make it display the sum of the column values by using the-t option.
Size-t [file1] [file2]...
The following is a screenshot of the execution of the command:
How to make size command show totals of all object files
The-t option adds the last line to it.
Q5. How do I get size to output the total size of common symbols in each file?
If you provide multiple input files for size as parameters, and you want it to display the size of the common symbol (symbol in common segment) in each file, you can take the-common option.
Size-- common [file1] [file2]...
It is also important to note that when using the Berkeley format, the size of these common symbols is included in the bss size.
Q6. What other options are there?
In addition to the options just mentioned, size has some general command-line options, such as v (to display version information) and-h (a summary of optional arguments and options).
What are the other available command line options
In addition, you can also use the @ file option to have size read the command line options from the file. The following is a detailed description:
The read option inserts and replaces the original @ file option. If the file does not exist or cannot be read, the option will not be replaced, but will be interpreted literally. The options in the file are separated by spaces. When you want to include spaces in an option, you need to enclose the entire option in single or double quotes. Any character, including the backslash itself, can be included in the option by adding a backslash before the character. The file itself can also contain other @ file options; any such option will be processed recursively.
Conclusion
Obviously, the size command does not apply to everyone. Its target group is those who need to deal with the object file / executable file structure in Linux. So, if you happen to be the target audience, try more of the options we've mentioned here, and you should be prepared to use this tool every day. For more information about size, read its man page.
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.