Monday, June 3, 2013

Linux Beginners will learn the 60 commands

Linux will learn the commands Linux provides a large number of commands, which can effectively use a lot of work done, such as disk operations, file access, directory operations, process management, file permissions settings. So, working on a Linux system without using system commands. To truly understand the Linux system, you must learn from the Linux command by command based learning can be further understood Linux systems.
Different Linux distributions not the same as the number of commands, but at least Linux distributions also have more than 200 orders. Here I put the more important and most frequently used commands, according to their role in the system introduced one by one into the following six parts.
◆ Installation and login commands: login, shutdown, halt, reboot, install, mount, umount,      chsh, exit, last;
◆ file processing command: file, mkdir, grep, dd, find, mv, ls, diff, cat, ln;
◆ System Management Related commands: df, top, free, quota, at, lp, adduser, groupadd, kill, crontab;
◆ Network Operation Command: ifconfig, ip, ping, netstat, telnet, ftp, route, rlogin, rcp, finger, mail, nslookup;
◆ System security related commands: passwd, su, umask, chgrp, chmod, chown, chattr, sudo ps, who;
◆ Other commands: tar, unzip, gunzip, unarj, mtools, man, unendcode, uudecode.
In this paper, Mandrake Linux 9.1 (Kenrel 2.4.21) as an example, under Linux installation and login commands.
login
1 action
login role is to log into the system, and its use permissions to all users.
(2) Format
login [name] [-p] [-h hostname]
3 main parameters
-P: Notification login to maintain the current environmental parameters.
-H: is used to transfer between remote login user name.
If you choose to use Linux command line login, then see the first Linux command is login:.
General Interface is this:
Manddrake Linux release 9.1 (Bamboo) for i586
renrel 2.4.21-0.13mdk on i686/tty1
localhost login: root
password:
The above code, the first line is Linux distribution version number, the second line is the kernel version number and login virtual console, in the third line we enter the login name and press "Enter" key to enter the account password in the Password, you can login system. For security reasons, enter the account password characters are not echoed on the screen, the cursor does not move.
Login will see the following screen (with super user):
[Root @ localhost root] #
last login: Tue, Nov 18 10:00:55 on vc/1
Above the display is logged week, month, date, time, and use the virtual console.
4 Application Tips
Linux is a true multi-user operating system, you can also accept multiple user logins, but also allows a user to log in multiple times. This is because many versions of Linux and Unix, as provides a virtual console access method, allowing users at the same time from the console (the system console is directly connected with the system monitor and keyboard) for multiple logins. Each virtual consoles can be seen as a stand-alone workstation, the table can be switched between.Switching virtual console by pressing the Alt key and a function key to achieve, usually using F1-F6.
For example, users log in, click "Alt + F2" key, the user can see the above message appears "login:" prompt, indicating that the user sees the second virtual console. Then simply press "Alt + F1" key, you can return to the first virtual console. A newly installed Linux system allows users to use "Alt + F1" to "Alt + F6" key to access the first six virtual consoles. Virtual Console most useful is that when a program error caused a system deadlock, you can switch to another virtual console work, close the program.
shutdown
1 action
shutdown command is to shut down the computer, it is the superuser permissions.
(2) Format
shutdown [-h] [-i] [-k] [-m] [-t]
3 Important Parameters
-T: changing to another run level before telling init program how long after the shutdown.
-K: do not really shutdown, only to send warning signals to each registrant.
-H: power off after shutdown.
-C: cancel current process to cancel the shutdown process is currently running. So this option is of course no time parameters, but you can enter a message to explain, and this information will be sent to each user.
-F: when you restart the computer forced fsck.
-Time: the time before setting off.
-M: the system to single-user mode.
-I: Displays system information when shutdown.
4 Command Description
shutdown command can be safely shut down the system. Some users will use a direct way to shut off the power and Linux systems, this is very dangerous.Because Linux and Windows, which many processes running in the background, so the forced shutdown process may lead to data loss, so that the system is in an unstable state, and even in some systems will damage the hardware device (hard drive). Before shutting down the system using the shutdown command, the system administrator will notify all registered users of the system to shut down, and login instructions will be frozen, that new users can not log on.
halt
1 action
halt command is to shut down the system, it is the superuser permissions.
(2) Format
halt [-n] [-w] [-d] [-f] [-i] [-p]
3 Main Parameter Description
-N: to prevent the sync system call, it is used in repair with fsck the root partition, to prevent the kernel with the old version of the super-block cover patched superblock.
-W: not really restart or shut down, just write wtmp (/ var / log / wtmp) record.
-F: do not call shutdown, while the forced shutdown or restart.
-I: shutdown (or reboot) before, turn off all network interfaces.
-F: forced shutdown, this directive does not call shutdown.
-P: the way to do it when the shutdown power off action.
-D: shut down the system, but does not leave a record. 
4 Command Description
halt is to call shutdown-h. halt execution, kill the application process, perform sync (to the data stored in the buffer is written to disk in compulsory) system call, file system write operation is completed will stop the kernel. If the system run level is 0 or 6, then shut down the system; otherwise to the shutdown command (plus-h parameter) instead. 
reboot
1 action
The role of the reboot command to restart the computer, it is the system administrator permission.
(2) Format
reboot [-n] [-w] [-d] [-f] [-i]
3 main parameters
-N: do not do before rebooting the hard drive memory data write-back operation.
-W: does not really re-boot, just put the records are written to / var / log / wtmp file.
-D: do not put records are written to / var / log / wtmp file (-n This parameter contains a-d).
-I: in before the first reboot all network-related device to stop.
install
1 action
The role of the install command to install or upgrade your software or backup data, its use permissions to all users.
(2) Format
(1) install [option] ... Source Destination
(2) install [option] ... SOURCE ... DIRECTORY
(3) install-d [option] ... directory ...
In the first two formats, will <source> Copy to <destination> or put more <source> file copied to an existing <Menu>, while setting permission modes and owner / group. In the third format, create all the specified directories and their home directory. The parameters of long options are mandatory for short options too necessary.
3 main parameters
- Backup [= CONTROL]: for each existing destination file backup.
-B: like - backup, but does not accept any parameters.
-C: (This option is not processed).
-D, - directory: all arguments as directory names, and will create the specified directory of all home directories.
-D: Create <destination> in front of all the main directory, and then put <source> Copy to <destination>; using the format in the first useful.
-G, - group = Group: set group ownership, instead of process' current group.
-M, - mode = mode: Self-setting permission modes (like chmod), instead of rwxr-xr-x.
-O, - owner = Owner: set ownership (super-user only applicable).
-P, - preserve-timestamps: the <source> file access / modification time as the corresponding destination file time attributes.
-S, - strip: a strip command removes symbol table, only applies to the first and second use format.
-S, - suffix = suffix: specify your own backup files <suffix>.
-V, - verbose: processing each file / print the name of the directory.
- Help: show this help message and exit.
- Version: Display version information and exit.
mount
1 action
mount command is to load the file system, it is the super-user with privileges or / etc / fstab allowed users.
(2) Format
mount-a [-fv] [-t vfstype] [-n] [-rw] [-F] device dir
3 main parameters
-H: displays auxiliary information.
-V: Displays information, usually used for debugging and-f.
-A: the / etc / fstab file systems defined in all hang.
-F: This command is usually used in conjunction with-a, it will mount for every action produces a stroke is responsible for implementation. The system needs to mount a large number of NFS file system can accelerate the speed of loading.
-F: typically used for debugging. It will mount does not perform the actual hanging of action, but to simulate the whole process of hanging, usually used in conjunction with the-v.
-T vfstype: Display the loaded file system type.
-N: Generally, mount will hang in the /etc/mtab to write a data in the system can be written to the file system is not the case, you can use this option to cancel this action.
4 Application Tips
On Linux and Unix systems, all files are as a large tree (with / as root) part of the visit. To access the files on the CD-ROM, CD-ROM devices need to be mounted in a hanging file tree decorated. If the release is installed automatically mount package, then this step can be performed automatically. In Linux, if you want to use the hard disk drives and other storage devices, you have to put it loaded hung up when the storage device, you can use it as a directory to access. Mount a device using the mount command. Use the mount command in this, at least first know the following three types of information: the object to load the file system type, the device name of the object to be loaded and should equipment be loaded into which directory.
(1) Linux file system can be identified
◆ Windows 95/98 used FAT 32 file system: vfat;
◆ Win NT/2000 file system: ntfs;
◆ OS/2 file system used: hpfs;
◆ Linux file system used: ext2, ext3;
◆ CD-ROM disc with a file system: iso9660.
Although vfat is FAT 32 system, but in fact it is also compatible with FAT 16 file system type.
(2) determine the name of the device
In Linux, the device name is usually present in / dev. These devices are all named after the name of the rule, you can use the "reasoning" way to find out the device name. For example,     /dev/hda1 this IDE devices, hd is the Hard Disk (HDD) is, sd is a SCSI Device, fd is Floppy Device (or Floppy Disk?). A represents a first device, usually IDE connector can connect four IDE devices (such as four hard drives). Therefore, a method to identify the IDE hard disk difference is hda, hdb, hdc, hdd. hda1 in the "1" hda represents the first hard disk partition (partition), hda2 hda represents a second primary partition, the first logical partition from hda5 start, and so on. Additionally, you can directly check the / var / log / messages file can be found in the file system after the computer boot device code has recognizable.
(3) Find a mount point
Before the decision to mount the equipment, first look at the computer is not there a / mnt empty directory, which is specifically used as a mount point (Mount Point) directories. Recommended /mnt built in several /mnt/cdrom, /mnt/floppy, /mnt/mo etc. directory, as a dedicated mount point directory. For example, if you want to mount the following five devices, which executes instructions may be as follows (assuming all the Linux ext2 system, if it is Windows XX Please change the ext2 vfat):
Floppy ===> mount-t ext2 /dev/fd0 /mnt/floppy
cdrom ===> mount-t iso9660 /dev/hdc /mnt/cdrom
SCSI cdrom ===> mount-t iso9660 /dev/sdb /mnt/scdrom
SCSI cdr ===> mount-t iso9660 /dev/sdc /mnt/scdr
But now most newer Linux distributions (including Red Flag Linux, the soft Linux, Mandrake Linux, etc.) can be automatically mounted file system, but other than Red Hat Linux.
umount
1 action
umount command is to uninstall a file system, it is the superuser permissions or / etc / fstab allowed users.
(2) Format
unmount-a [-fFnrsvw] [-t vfstype] [-n] [-rw] [-F] device dir
3 Instructions for use
mount command umount command is the inverse operation, its parameters and the use of methods and the mount command is the same. Linux mounted the CD-ROM, it will lock the CD-ROM, CD-ROM so can not be used on the front panel Eject button to eject it. However, when the disc is no longer needed, if has / cdrom as a symbolic link, use the umount / cdrom to unmount it. Only when no user is using a disc, the command to succeed. The command includes the current working directory with the CD-ROM directory as the terminal window.
chsh
1 action
chsh command is to change the user shell settings, and its use permissions for all users.
(2) Format
chsh [-s] [-list] [- help] [-v] [username]
3 main parameters
-L: show all Shell type.
-V: Displays Shell version number.
4 Application Tips
In front of Linux has a variety of Shell, general default is Bash, if you want to replace Shell types can use the chsh command. First enter the account password, and then enter the new Shell type, if done correctly the system displays "Shell change". Its interface is generally as follows:
Changing fihanging shell for cao
Password:
New shell [/bin/bash]:/bin/tcsh
The above code, [] is currently used within Shell. Ordinary users can modify their own Shell, the super user can modify all the user's Shell. To query system which Shell, you can use the chsh-l command, shown in Figure 1.
Figure 1 system can use the Shell type
As can be seen from Figure 1, the author of the system can be used with Shell bash (the default), csh, sh, tcsh of four.
exit
1 action
The role of the exit command to exit the system and its use permissions to all users.
(2) Format
exit
3 Parameters
exit command with no arguments, exit the system after running into the login screen.
last
1 action
last command is to display recent user or terminal logins, its use permissions to all users. By last command to view the program's log, the administrator can be informed of who has ever or attempted connection system.
(2) Format
1ast [-n] [-f file] [-t tty] [-h node] [-I-IP] [-1] [-y] [1D]
3 main parameters
-N: Specifies the number of output records.
-F file: Specifies the file with the file used as the query log file.
-T tty: shows only the specified virtual console logins.
-H node: Displays only the specified node logins.
-I IP: Show only specified IP logged on the case.
-1: Used to display the remote IP address.
-Y: Show record year, month, and day.
-ID: know the user name queries.
-X: Display system shutdown, user log in and out of history.
Hands-on exercises
The above describes the Linux installation and login commands, the following are a few examples of what I just talked about hands-on exercises command.
1 run multiple commands
In a command line, you can execute multiple commands, the individual commands are separated by semicolons can be, for example:
# Last-x; halt
The above code means that the display system shutdown, user login and shut down the computer after exiting history.
2 Use mount to mount the file system access to Windows system
Many Linux distributions can now be automatically loaded Vfat partition to access the Windows system, and various versions of Red Hat are not automatically loaded Vfat partition, it also needs to be done manually.
can mount a Windows partition as a Linux "file" attached to Linux an empty folder, thus bringing the Windows partition and / mnt This directory link. Therefore, as long as access to the folder is equivalent to access the partition. First in the / mnt folder created under winc at the command prompt, enter the following command:
# Mount-t vfat / dev/hda1 / mnt / winc
Means that the C partition for Windows Liunx linked to the / mnt / winc directory. Then, in the / mnt / winc directory in Windows, you can see the contents of the C drive. Using a similar method can access the Windows system D, E drive. In the Linux system displays the Windows partition general order this: hda1 as the C drive, hda5 for the D drive, hda6 as E drive ...... and so on. The method can view the Windows system has a big problem, that is, all the Chinese in Windows file names or folder names appear as a question mark "?", But they can be displayed in English. We can add some parameters to make it display Chinese. Also to the operation of the above example, then enter the command:
# Mount-t vfat-o iocharset = cp936 /dev/hda1 /mnt/winc
Now it can properly display Chinese.
3 Use the mount to add a file system on the flash drive
Under Linux flash drive is very simple to use. Linux on the USB device has good support, when inserted flash drive, flash drive is recognized as a SCSI disk, usually enter the following command:
# mount /dev/sda1 /usb
Will be able to add a file system on the flash drive. ()

(* (Volatile unsigned char *) 0x20)

For the (volatile unsigned char *) 0x20 Let us analyze, which is composed of two parts: 



1) (unsigned char *) 0x20, 0x20 is just a value, preceded (unsigned char *) indicates 0x20 is an address, but this address type is unsigned char, meaning that read and write to this address, unsigned char values ​​to be written into and read out is unsigned char. 


2) volatile, volatile keyword to ensure that this directive will not be optimized C compiler have been omitted, and require each direct reading. For example while ((unsigned char *) 0x20), sometimes the system might not actually read the value of 0x20, but with the first read-out value, if so, then the loop may be an endless loop. With a volatile read is required every time the actual value of 0x20. Then (volatile unsigned char *) 0x20 is a fixed pointer is immutable, not a variable. The char * u is a pointer variable. And then in the front plus "*": * (volatile unsigned char *) 0x20 becomes a variable (unsigned char variables common and not a pointer variable), if # define i (* (volatile unsigned char *) 0x20), then with unsigned char i is the same, but in front of the address of i is fixed. So your question can be answered, (* (volatile unsigned char *) 0x20) can be regarded as a normal variable, this variable has a fixed address, pointing to 0x20. The 0x20 is just a constant, not a pointer but not variable.

Instructions for use mkimage

mkimage image file in the production time, the original image file before the increase of the head of a 0x40 byte length, the increase in head structure is described below
/ *
 Image * Legacy format header,
 * All Data in Network byte Order (aka Natural aka bigendian).
 * /
typedef struct image_header {
    uint32_t ih_magic; / * Header Image Magic Number * /
    uint32_t ih_hcrc; / * Image Header CRC Checksum * /
    uint32_t ih_time; / * Image Creation Timestamp * /
    uint32_t ih_size; / * Image Data Size * /
    uint32_t ih_load; / * Data Load Address * /
    uint32_t ih_ep; / * Entry Point Address * /
    uint32_t ih_dcrc; / * Image Data CRC Checksum * /
    uint8_t ih_os; / * Operating System * /
    uint8_t ih_arch; / * CPU architecture * /
    uint8_t ih_type; / * Image Type * /
    uint8_t ih_comp; / * Compression Type * /
    uint8_t ih_name [IH_NMLEN]; / * Image Name * /
} image_header_t;
Image Name takes up 32 bytes, the other takes up 32 bytes of information
mkimage Usage:
Usage:. / Mkimage-L Image
          -L ==> List Image header information
       . / mkimage [-x]-A Arch-O OS-T type-C COMP-a addr-e EP-N name-d data_file [: data_file ...] Image
          -A ==> set architecture to 'Arch'
          -O ==> Operating system set to 'OS'
          -T ==> set Image type to 'type'
          -C ==> set compression type ' COMP '
          -a ==> set Load address to 'addr' (hex)
          -e ==> set entry Point to 'EP' (hex)
          -N ==> set Image name to 'name'
          -d ==> Use Image Data from 'datafile'
          -x ==> set XIP (execute in place)
       . / mkimage [-D dtc_options]-f-image.its FIT FIT-Image
-A set architecture types, values ​​refer uboot / common / image.c
-O set the type of operating system, you can refer to the value uboot / common / image.c
-T image types, values ​​refer uboot / common / image.c
-A Specifies the image in memory load address
-E Specifies the address of the entry point to run image
-C specifies compression, compression reference uboot / common / image.c
-D data_file [: data_file ...] making image source files

Example
 $ MKIMAGE_TOOL-A arm-O linux-T kernel-C none-a 0x90008000-e 0x90008000-n "Android Linux Kernel"-d./ZImage./UImage

Information on how to get the console output to the LCD

Information is to allow simultaneous output to the console LCD:
1 Compile the kernel, adding CONFIG_FRAMEBUFFER_CONSOLE = y
2 In uboot add console = tty0

RTC when to update the system time

RTC - real time clock maintains the system hardware time when linux boot when needed RTC hardware clock setting system time.
This process is in drivers / rtc / hctosys.c drive to achieve, and the driver is actually only an init function, and put its own init function is declared as
late_initcall, so you can ensure the normal operation of RTC driver already.
init function from the RTC device reads the current hardware clock, then call do_settimeofday rewrite the system clock.

27 static int __ init rtc_hctosys (void)
 28 {
 29 int ERR =-ENODEV;
 30 rtc_time struct tm;
 31 struct timespec TV = {
 32. tv_nsec = NSEC_PER_SEC >> 1,
 33};
 34 struct rtc_device * rtc = rtc_class_open (CONFIG_RTC_HCTOSYS_DEVICE) ;
 35
 36 IF (rtc == NULL) {
 37 pr_err ("% s: Unable to Open rtc device (% s) \ N",
 38 __ FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
 39 GOTO err_open;
 40}
 41
 42 ERR = rtc_read_time (rtc , & tm);
 43 IF (ERR) {
 44 DEV_ERR (rtc-> dev.parent,
 45 "hctosys: Unable to Read the Hardware clock \ N");
 46 GOTO err_read;
 47
 48}
 49
 50 ERR = rtc_valid_tm (& tm) ;
 51 IF (ERR) {
 52 DEV_ERR (rtc-> dev.parent,
 53 "hctosys: invalid Date / time \ N");
 54 GOTO err_invalid;
 55}
 56
 57 rtc_tm_to_time (& tm, & tv.tv_sec);
 58
 59 do_settimeofday (& TV);
 60
 61 dev_info (rtc-> dev.parent,
 62 "setting system clock to"
 63 "% d-% 02d-% 02d% 02d:% 02d:% 02d UTC (% u) \ N",
 64 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
 65 tm.tm_hour, tm.tm_min, tm.tm_sec,
 66 (unsigned int) tv.tv_sec);
 67
 68 err_invalid:
 69 err_read:
 70 rtc_class_close (rtc );
 71
 72 err_open:
 73 rtc_hctosys_ret = ERR;
 74
 75 return ERR;
 76}
 77
 78 late_initcall (rtc_hctosys);

34 Get RTC device
Read the time from the RTC device 42, rtc_read_time just read rtc time subsystem interface functions, the real read operation is in particular implemented RTC hardware drivers
50 The return value is a tm structure, rtc_valid_tm verify the legality of the return value
57 is converted to UTC seconds format
59 Setting the System Time
78 to ensure that this is the last call initialization function, at least in the RTC driver called after initialization

SDTV EDTV and HDTV

SDTV Standard-definition TV standard definition TV
EDTV Enhenced-definition TV Enhanced Definition TV
HDTV High-definition TV HDTV

Including 480i 576i SDTV
Including 480p 576p EDTV
HDTV 720P 1080i 1080p

480i: i indicates interlaced interlaced mean, 480 indicates the frame is 480 lines of vertical resolution, horizontal resolution is generally 720,704,480 i corresponds to the NTSC TV standard
576i: Vertical resolution 576 lines, corresponding to the PAL TV system
480p/576p: p represents progressive progressive meaning
720p: 1280x720
1080i/1080p: 1920x1080

container_of understanding

container_of (pointer, container_type, container_field)
pointer: points to be included in the address of the container_field
container_type: the type of structure that contains container_field
container_field: container_type a member name

The macro structure via a pointer container_type container_field pointer address, return address of the structure of this container_type
Acer to achieve
/ ** 
* container_of - cast a Member of a Structure out to the containing Structure 
* @ PTR: the pointer to the Member. 
* @ type: the type of the container struct this is Embedded in. 
* @ Member: the name of the Member within the struct. 

* / 
# define container_of (PTR, type, Member) ({/ 
         const typeof (((type *) 0) -> Member) * __mptr = (PTR); / 
         (type *) ((char *) __mptr - offsetof (type, member));})

typeof (((type *) 0) -> member)
Gets the type of the structure member members

About offsetof
# Define offsetof (TYPE, MEMBER) ((size_t) & ((TYPE *) 0) -> MEMBER)
Members MEMBER return the offset in the TYPE

Analysis touchscreen hops

Took over a touch screen bug, touch screen occasionally occur hops, four-wire touch screen, pmic13892 sampled including coordinates and contact-resistance

Assumed that contact-resistance maximum and minimum, respectively resist_max, resist_min
After observed hops occur in two situations:
1 Using the stylus, nail tip and other hard objects leaving the screen the moment will occur hops, hops occur when the contact-resistance sample values ​​greater than resist_min, and less than resist_max
2 Use the belly occur frequently hops, then contact-resistance sampled value is greater than resist_min, less than resist_max, coordinate sampling value is very accurate, and a wide range of hops occur frequently

In the first case, can indeed be filtered to drive the contact-resistance of the sample data is not correct
But for the second case, it can be concluded that pmic or touch screen hardware problem, the software can not the perfect solution

There are many online correction algorithm, in fact, think many of them are irresponsible, first find the root of the problem is not trying to pass another set of problems botched correction algorithm
The resulting impact on performance

I encountered another problem touchscreen, touch sampled sound playback effect, this typical hardware requires software to circumvent the problem is, in fact, only minor modifications to the lower end hardware
To solve the hops 
Sometimes clumsy approach can temporarily solve the problem quickly, but you can never lose the opportunity to know the truth

Some basic knowledge of framebuffer

Horizontal and Vertical flyback retrace the introduction of the concept of a CRT, an electron beam drawing a horizontal line from left to right, back to the next column header to continue scanning the next line until the bottom line of the screen, then back to the top of the screen to continue to the next frame scanning.
Horizontal retrace: electron beam is emitted from the end of the previous line to the next line start point of the time required
Frame flyback: Electron beam from the bottom of the screen to move to the top of the screen time needed
 CRT screen refresh rate is how calculated:
Assume graphics dotclock is 28.37516MHZ
1 then the scan time for each point is 1 / (28.37516E6 Hz) = 35.242E-9 s
(2) If the screen resolution is 640x480 refresh his need 640 * 35.242E-9s = 22.555E-6s, taking into account the horizontal retrace need to take some time, assuming 272 'pixels'
    (640 +272) * 35.242E-9s = 32.141E-6s
3 can be called horizontal scanning frequency of
    1 / (32.141E-6s) = 31.113E3HZ, i.e. 31KHz
4 For a 480 line, plus the frame flyback, assuming the frame flyback is 49 'lines'
    (480 +49) * 32.141E-6s = 17.002E-3s
    Can calculate the frame scanning frequencies are:
    1 / (17.002E-3s) = 58.815Hz
That refresh rate is 59Hz
 Line sync HSYNC: Every one pulse, means a new line starts sending data
Frame synchronization VSYNC: Every one pulse, means a new start sending a screen image data
 The frame sync and line sync head and tail must be left flyback time, such an arrangement of a CRT monitor originated the time deflection of the electron gun, and a standard, so TFT LCD display also includes a flyback time
  
xres: the horizontal resolution of the screen
yres: the vertical resolution of the screen
Common embedded device's LCD resolution is 320 * 240 primary, 640 * 480

Reference to the kernel/Documentation/fb/framebuffer.txt

ioremap return address

ioremap and vmalloc same area will return vmalloc virtual address, but does not allocate any ioremap physical memory, ioremap also need to create a new page table to access the physical page.
ioremap obtain the virtual address space needed to release iounmap.

ioremap main device used to map physical memory into the kernel's virtual address space, so that the kernel virtual address space can be accessed through the device memory.
Use ioremap points to note:
1 Try not directly access these virtual addresses, using a dedicated function io operations can increase the portability, of course, some special cases, such as android pmem is the physical memory of ioremap, so you can directly access the memory
(2) In some cases, you may not want the system cache to play a role, this time to be mapped using ioremap_nocache

Today accidentally hit the next ioremap return address, is actually 0x9c820000, rather than 0xCxxx xxxx
Again OK to print the address code no problem, check the code did not find out where the problem, and finally found the answer dmesg    
Virtual kernel memory layout:
    Vector: 0xffff0000 - 0xffff1000 (4 kB) 
    fixmap: 0xFFF00000 - 0xfffe0000 (896 kB) 
    DMA: 0xf9e00000 - 0xFFE00000 (96 MB) 
    vmalloc: 0x9c800000 - 0xf4000000 (1400 MB) 
    lowmem: 0x80000000 - 0x9c000000 (448 MB) 
    pkmap: 0x7fe00000 - 0x80000000 (2 MB) 
    modules: 0x7F000000 - 0x7fe00000 (14 MB) 
      . init: 0x80008000 - 0x8004e000 (280 kB) 
      . text: 0x8004e000 - 0x8086a000 (8304 kB)
      . Data: 0x80892000 - 0x808dfba0 (311 kB)

Appears to be defined as the 2G ~ 4G kernel space, and returns exactly ioremap address is within the address range vmalloc.

ZONE_MOVABLE role

In 2.6.20-rc4 in, mel Gorman submitted the patch introduces ZONE_MOVABLE, introducing the pseudo zone is intended to prevent memory fragmentation zone
ZONE_MOVABLE indicates that the zone can only be marked with __GFP_HIGHMEM and __GFP_MOVABLE distribution and use. This makes all non-movable pages are restricted to a single memory area, and movable in the area of ​​memory allocated by other satisfied.
Movable zone by the size of the kernel parameter "kernelcore =" designation. This parameter specifies how much memory is allocated to ZONE_MOVALBE. In ZONE_MOVABLE zone within the pages can be released through migrating or reclaiming lost.
When we choose a zone for ZONE_MOVABLE page, you need to consider two points:
First of all, only at the highest memory zone of memory for ZONE_MOVABLE. For x86 platform, ZONE_HIGHMEM; For ppc64 is ZONE_DMA; For x86_64 is ZONE_DMA32.
Secondly, the kernel memory may be used by a flat distributed across multiple NUMA nodes. If the node is not the same size, it will cause a kernel on different nodes of different amount of memory used.
By default, this zone is not used as huge pages allocation because huge pages allocation is fixed and non-migratable. Provides a sysctl hugepages_treat_as_movable allows ZONE_MOVABLE run huge pages allocated. This means that when the system after the system call is executed, huge page pool dimensions contained ZONE_MOVABLE size.
Apart hugh pages may be non-ovable, no introduction of the other possible cause ZONE_MOVABLE distribution outside debris.

__GFP_MOVABLE
Use this flag to the allocated memory, or you can move through the page migration mechanism, or can be synchronized to the backing storage of the page to recover.

LDS file format analysis


When you look at the recent Linux kernel, and the connection is always encounter some scripts related stuff, and made people confused, finally decided to thoroughly understand it, write a little experience, and want to help people like me ! 
    
Connection script format 
====================
Connection script is a text file.

You wrote a series of commands as a linker script. Every command with parameters is a keyword, or one pair of symbolic assignment you can 
use a semicolon to separate the commands. spaces are generally ignored.


File name or format name of the class string can generally be typed directly if the file name contains special characters, such as generally used as a comma delimited file name 
number, you can put the file name into double quotes. intermediate file name can not be used double quotes.

You can, as in the C language, as in linker script using annotations, using the '/ *' and '* /' separated, just like in C, comments are syntactically equivalent to whitespace.

Simple connection script example 
============================
Many scripts are fairly simple.
The most simple script may contain only one command: 'SECTIONS'. You can use the 'SECTIONS' to describe the memory layout of the output file.

'SECTIONS' is a very powerful command here which we will describe a very simple to use, let us assume that your program is only a code section, 
initialized data section, and uninitialized data section. these will exist in '. text', '. data' and '. bss' section, in addition, let us into a 
further assume that in your input file only those sections.


For this example, we say that the code should be loaded into the address '0 x10000 'office, and the data should be from the beginning at 0x8000000 The following is a realization of 
this function script:

    SECTIONS
    {
      . = 0x10000;
      . text: {* (. text)}
      . = 0x8000000;
      . Data: {* (. Data)}
      . BSS: {* (. BSS)}
    }
You use the keyword 'SECTIONS' wrote the SECTIONS command, followed by a string of symbols in braces assignment and output section describes the contents of the.

The above example, the 'SECTIONS' command in the first line is a special symbol '.' Assignment, which is a location counter if you do not have in its 
way it specifies the address of the output section (in the back would otherwise description), that value will be set to the address of the location counter existing value. location counter 
and the size of the output section is added in 'SECTIONS' command at the beginning of the location counter has the value '0 '.


The second line defines an output section, '. Text'. Colon is required syntax can now be ignored. Section name behind the curly braces, you list all should be 
placed into the output section of the input section name. '*' is a wildcard matching any file name. expressions '* (. text)' means that all the input 
into the file '. text' input sections.


Because when the output section '. Text' definition, positioning counter value is '0 x10000 ', the connector will output file'. Text 'section of the address set 
to '0 x10000 '.


The remaining contents of the definition of the output file '. Data' section and '. Bss' section. Connector will'. Data 'output section into the address '0 x8000000' office. Connection 
is put away '. data' output section after positioning counter value is '0 x8000000 'plus'. data' output section length. obtained result is the connector will 
put '. bss' output section is placed immediately '. data' section of the back position.


Connector necessary by increasing the value of the location counter to ensure that each section has its output aligned with the desired, in this case, in order to '. Text' 
and '. data' section specified address alignment constraints satisfied, but the Connector may need to '. data' and '. bss' section to create a small gap between.

In this way, it is a simple but complete connection script.
Simple connection script commands. 
=============================
In this chapter, we will describe some simple scripting commands.
Set the entry point.
-----------------------
When you run a program to be executed first instruction called "entry point." You can use the 'ENTRY' connection script command to set the entry point. Argument
is a symbol name:
    ENTRY (SYMBOL)
There are many different ways to set the entry point. Connector by sequentially try the following methods to set the entry point, if successful, will stop.
  * `-E 'entry command-line option;
  * Connect the script `ENTRY (SYMBOL) 'command;
  * If you define the start, on the use of start values;
  * If there is, use '. Text' section of the first address;
  * Address `0 '.
Document processing commands. 
---------------------------
There are several processing documents linking script commands.
`INCLUDE FILENAME '
in the current script file that contains the connection point FILENAME. in the current path or use the '-L' option specifies the path to search for all the files,
you can nest 'INCLUDE' up to 10 layers.
`INPUT (FILE, FILE, ...) '
`INPUT (FILE FILE ...) '
'INPUT' command instructs the connector connection include file, as they are the same as specified on the command line.
For example, if you connect it always contains the file 'subr.o', but every time you connect to the command line, enter bored
, you can connect to your script, enter 'INPUT (subr. o).
In fact, if you like, you can put all your input files listed in the linker script, and then when the connection does not need anything,
as long as a '-T' option is enough.
In a 'system root prefix' is configured in the case, if a file name with a '/' character starts, and the script is also stored in the system root
prefix a subdirectory, the file name will be in the system root prefix search under. Otherwise, the connector will attempt to open the file in the current directory
pieces, if not found, the connector through the archives library search path to search.
If you use a 'INPUT (-lFILE)', 'ld' will convert the file name 'libFILE.a', like a command line parameter '-l' the same.
When you are in an implicit connection scripts 'INPUT' command, the file will be connected to the connection point of the script file to be included on
is included in. This will affect the file search.
`GROUP (FILE, FILE, ...) '
`GROUP (FILE FILE ...) '
In addition to the archive file must all be outside, 'GROUP' command with 'INPUT' similar, they will be repeated searches, until there is no undefined
references are created.
`OUTPUT (FILENAME) '
'OUTPUT' command names the output file in connection scripts' OUTPUT (FILENAME) 'command with the command line using the'-O
FILENAME 'commands are equivalent if the two are used that command line option takes precedence.
You can use the 'OUTPUT' command to create a default output file name of the file, instead of the usual 'a.out'.
`SEARCH_DIR (PATH) '
`SEARCH_DIR 'command to the' ld 'is used to search for the file path of the file to add the new path. use` SEARCH_DIR (PATH)' with the
command line using the '-L PATH' option is a completely other effective if two are used, and that all connectors are two paths to search. Yongming
command line option to specify the path is searched first.
`STARTUP (FILENAME) '
Apart FILENAME will be the first to be connected to the input file, 'STARTUP' command with 'INPUT' command exactly alike, as this text
piece is the first one on the command line is the same as the specified file. If in a system, the entry point is always present in the first file, then
this is useful.
Processing object file format commands. 
-----------------------------------------
There are two processing object file format linker script command.
`OUTPUT_FORMAT (bfdname) '
`OUTPUT_FORMAT (DEFAULT, BIG, LITTLE) '
`OUTPUT_FORMAT 'command for the output file format used by BFD named using` OUTPUT_formAT (BFDNAME)' with the command line
using the '-oformat BFDNAME' is entirely etc. effective if two are used, the command line option takes precedence.
You can use the `OUTPUT_formAT 'with three parameters to use when different based'-EB 'and'-EL 'command line option format.
If the '-EB' and '-EL' are not used, then the output format will be the first argument DEFAULT, if you use the '-EB', the output format will be the
second parameter BIG, if you use the '-EL' The output format will be the third parameter, LITTLE.
For example, the default platform based on MIPS ELF linker script using the following command:
        OUTPUT_formAT (elf32-bigmips, elf32-bigmips, elf32-littlemips)
    This means that the default output file format is 'elf32-bigmips', but when the user uses '-EL' command line option, the output file will
    be in ` elf32-littlemips' format to create.
`TARGET (bfdname) '
'TARGET' command reads the input file name in the BFD format which does not affect the subsequent 'INPUT' and 'GROUP' command with the command
on the command line using the `-b BFDNAME 'similarity. If you use the 'TARGET' command but `OUTPUT_formAT 'is not specified, the last of
'TARGET' command can also be used to set the output file format.
Other connection script commands. 
----------------------------
There are some other connection script commands.
`ASSERT (EXP, MESSAGE) '
to ensure that EXP does not equal zero, if zero, the connector will return an error code to exit, and print out the MESSAGE.
`EXTERN (SYMBOL SYMBOL ...) '
mandatory SYMBOL as a non-defined symbols input to the output file. doing so may trigger a number of connections from the standard library
section outside the library, you can assign each EXTERN ' lists several symbols, but many times you can use the 'EXTERN'. this command with the '-u'
command line option has the same effect.
`FORCE_COMMON_ALLOCATION '
this command with the command line option '-d' has the same effect: Even if you specify a relocatable output file ('-r'), but also to 'ld'
as an ordinary symbol distribution space.
`INHIBIT_COMMON_ALLOCATION '
this command with the command line option `- no-define-common 'has the same effect: even if it is a non-weight-bit output file, and let
'ld' ignored as ordinary symbols allocated space.
`NOCROSSREFS (SECTION SECTION ...) '
This command is encountered in some specific reference to the time between sections will produce an error message.
In certain programs, especially in the use of overlay technology embedded systems, when a section is loaded into memory, another section
will not be in memory. Any direct references between the two sections will was a mistake. example, if a section of code calls another
a section of a function, which will generate an error.
`NOCROSSREFS 'command output section with a list of names and if' ld 'encounter any cross-references between these sections, it
will report an error and returns a non-zero exit code. attention, `NOCROSSREFS 'command use the output section name, not the input section name.
`OUTPUT_ARCH (BFDARCH) '
Specify a particular output machine architecture. This parameter is used in a BFD library name you can use with the '-f' option
of 'objdump' program to view an object file structure.
The symbol assigned. 
===========================
You can connect in a script as a symbol assigned a value, which will define a symbol as a global symbol.
Simple assignment. 
------------------
You can use all of the C assignment symbol is a symbol assignments.
`SYMBOL = EXPRESSION; '
`SYMBOL + = EXPRESSION; '
`SYMBOL - = EXPRESSION; '
`SYMBOL * = EXPRESSION; '
`SYMBOL / = EXPRESSION; '
`SYMBOL << = EXPRESSION; '
`SYMBOL >> = EXPRESSION; '
`SYMBOL & = EXPRESSION; '
`SYMBOL | = EXPRESSION; '
The first case is defined as the value will SYMBOL EXPRESSION. Other cases, SYMBOL must have been defined, and the value will be adjusted accordingly
whole.
Special symbol name '.' Denotes the location counter. You can only 'SECTIONS' command to use it.
EXPRESSION behind the semicolon is a must.
Expressions are defined below.
Value of the expression you write when you can use them as a separate part, or as a 'SECTIONS' command in a statement, or as
'SECTIONS' command to describe a part of the output section.
Symbol's section will be set to an expression where the festival.
Here is a place in the three examples of using symbolic assignment:
    floating_point = 0;
    SECTIONS
    {
      . text:
        {
          * (. text)
          _etext =.;
        }
      _bdata = (. + 3) & ~ 3;
      . Data: {* (. Data)}
    }
In this example, the symbol `floating_point 'is defined as zero. Symbol'-etext 'is defined as the previous one'. Text 'end of the address section.
and the symbol '_bdata' may be defined as '. text' output section behind an upwardly aligned on a 4-byte boundary address value.
PROVIDE
-------
In some cases, a symbol is referenced to the time the connection is only defined in the script, and not to be connected at any one of the object file specified incoming
defined This approach is more sensible for example, a conventional connector definition a symbol 'etext'. However, ANSI C requires the user to be able to
'etext' as a function uses without generating an error. 'PROVIDE' keyword can be used to define a symbol, such as 'etext', this
definition is only in its is referenced to the time valid and invalid when it is defined. syntax is `PROVIDE (SYMBOL = EXPRESSION) '.
Here is a use of 'PROVIDE' define 'etext' examples:
    SECTIONS
    {
      . text:
        {
          * (. text)
          _etext =.;
          PROVIDE (etext =.);
        }
    }
In this example, if the program defines a '_etext' (with a leading underscore), the connector will give a redefinition error if,
the program defines a 'etext' (without the leading underscore), the connector define default program if the program refers to 'etext' but does not
define it, the connector will use the connection script definition.
SECTIONS command 
================
'SECTIONS' command tells the linker how to map input sections into output section, and how the output sections into memory.
'SECTIONS' command format is as follows:
    SECTIONS
    {
      SECTIONS-COMMAND
      SECTIONS-COMMAND
      ...
    }
SECTIONS-COMMAND each one may be the following:
  * A 'ENTRY' command.
  * A symbol assignment.
  * An output section description.
  * An overlapping description.
'ENTRY' command and symbol assignments in the 'SECTIONS' command is allowed, it is for the convenience of the location counter used in these commands, which can also be
connected to the script to make it easier to understand, because you can use in place of more meaningful these commands to control the output file layout.
Output Section Descriptor and overlapping descriptions are described below.
If you do not use the connection script 'SECTIONS' command, the connector will be encountered in the input file according to the order of sections in the same place each input section
names in the output section if all input sections are in the first a file exists, then the output file will match the order of the first section of an input file in
the order of sections The first section will address the zero point.
Output section describes 
--------------------------
A complete description of the output section should look like this:
    SECTION [ADDRESS] [(TYPE)]: [AT (LMA)]
      {
        OUTPUT-SECTION-COMMAND
        OUTPUT-SECTION-COMMAND
        ...
      } [> REGION] [AT> LMA_REGION] [: PHDR: PHDR ...] [ = FILLEXP]
Most of the output section does not use an optional section attributes here.
SECTION edge of space is a must, so section name is clear. Colon with braces is also necessary. Line breaks, and other spaces are optional.
Each OUTPUT-SECTION-COMMAND situation might be as follows:
  * A symbol assignment.
  * An input section description.
  * Directly contain data values.
  * A specific output section keyword. output section name. -------------------
 

Output section name is SECTION. SECTION must satisfy the constraints of your output format in one section only supports an unlimited number of formats, such as
'a.out', the name must be a format supported in a section name (eg , 'a.out' Only '. text', '. data' or '. bss'). If the
output format supports any number of sections, but only to support figures, and no name (as in the case of Oasys), name should be enclosed in double quotes with a
numeric string form. a section name can consist of any number of characters, but with a very contain arbitrary characters (such as comma) the words must be
in double quotation marks.
Output section describes 
--------------------------
ADDRESS is the output section of the VMS on an expression, if you do not provide ADDRESS, connector based REGION (if it exists) to set it up, or
those based on the current value of the location counter.
If you provide ADDRESS, the address of that output section will be precisely set to this value if you do not provide neither provides ADDRESS REGION, then
the address of the output section will be set up the current location counter aligned to the output section requires the alignment of the boundary value output section alignment requirements are all inputs
into the section containing the most stringent alignment requirements a.
For example:
    . text.: {* (. text)}
And
    . text: {* (. text)}
There are subtle differences. First one will '. Text' output section address is set to the current value of the location counter The second will set it to the location counter
aligned to the current value of upwards '. text' input sections aligned most demanding a border.
ADDRESS can be any expression; For example, if you need to put on the 0x10 byte boundary alignment sections, so you can make the low four-byte node address is
zero, you can do this:
    . Text ALIGN (0x10): {* (. Text)}
This statement can work because the 'ALIGN' returns the current location counter, and to align to the specified value.
Specify the address of a section will change the value of the location counter.
Input section description 
-------------------------
The most common output section command is an input section description.
Input section description is the most basic connection script actions you use to tell the linker output sections in memory layout of your program how you use the input section
to tell the linker how to map the input files to your memory.
Input section based 
---------------------------
An input section description consists of a file name followed by an optional bracketed section name lists.
File names and section names can appear as a wildcard, which we introduce later.
The most common input section description is included in the output section all input sections with a specific name, eg, containing all the input '. Text' section, you can
write:
    * (. Text)
Here, '*' is a wildcard, matches all filenames order to exclude the part of the file name wildcard matching outside, EXCLUDE_FILE can
be used to match all except in EXCLUDE_FILE file specified in the list, such as:
    (* (EXCLUDE_FILE (* crtend.o * otherfile.o). Ctors))
Let Apart `crtend.o 'files and` otherfile.o' files outside of all the documents in all. Ctors section is included.
There are two ways to include more than one sections:
    * (. Text. RDATA)
    * (. text) * (. RDATA)
The difference between the above two '. Text' and '. Rdata' input sections appear in the output section of a different order in the first example, the two sections alternately 
appear and to connect the input of the order of arrangement. In the second example, all '. text' input sections will appear first, followed by all '. rdata' section.
You can specify a file name from the file that contains a specific section if one or more of your files contain special data in memory, requiring special
special position, you can do this, such as:
    data.o (. data)
If you do not use a file name with a section of the list, and that all of the input file section will be included in the output section. Normally would not do, but
in some cases this can be very useful, such as:
    data.o When you use a wildcard does not contain any file name, the connector will first check whether you are connected to the command line specifies the file name or in the 'INPUT' command. If you do not, the connector will try to put this file as an input file to open, just as it appears on the same command line. attention to this with 'INPUT' command is not the same as the connector in the file search file search path.
   
Input section wildcard 
---------------------------------
In an input section description, file name or section name, or both can be a wildcard in the form.
File name wildcard '*' in many cases you can see, this is a simple file name wildcard form.
Wildcard forms used with Unix Shell same.
`* '
matches any number of characters.
`? '
match a single character.
`[CHARS] '
matches any single character in CHARS; character '-' can be used to specify a square Hong characters, such as [az] matches any small print characters.
`\ '
escapes the subsequent characters.
When a file name with a wildcard match, the wildcard characters will not match a '/' character (on UNIX systems used to separate directory names), one
containing a single '*' character in the form of an exception; it will always match any documents name, regardless of whether it contains a '/' in a section name, the wildcard character
character will match '/' character.
Filename wildcards only match those on the command line or in the 'INPUT' explicitly specified on the command file. Connector does not search directories to expand through the wildcard
character.
If a file name matches more than one wildcard, or if a file name appear explicitly while matching a wildcard, the connector will use the
first match to the connection script for example, the following section describes the input sequence is likely to be wrong , because 'data.o' rule is not being used:
    . Data: {* (. Data)}
    . DATA1: {data.o (. Data)}
Typically, the connector will match the wildcard file and the festival was seen by the connection placed in the order you can 'SORT' key to change it, it
appears in parentheses before the wildcard (eg, 'SORT (. text *) ') when' SORT 'keyword is used, the connector section in the file and put
the output file in the order prior to rearrange them by name.
If you enter the section is placed for where to go was very confused, then you can use the '-M' connection option to generate a bitmap file. Bitmap file will
accurately show how input sections are mapped to the output section.
This example shows how wildcard is used to distinguish file This connector connection script indicates all the '. Text' section into '. Text' in all the '. Bss' section into '. Bss' Connectors will put all the file names from the beginning with a capital letter in the file '. data' section into '. DATA' section; For all other files, the connector will '. data' section into ' . data 'section.
    SECTIONS {
      . text: {* (. text)}
      . DATA: {[AZ] * (. Data)}
      . Data: {* (. Data)}
      . BSS: {* (. BSS)}
    }
Input section ordinary symbols.
-----------------------------------
For ordinary symbol, require a special logo, because in many target format, the common symbol is not a particular input section. Connector will
handle normal symbols as if they are called 'COMMON' in a section.
You might like to use other input sections with the same file name to use with the 'COMMON' section of the file name. You can use this to come from a specific input
into the file into a common symbol section, while the input files from other common symbols into another section.
In most cases, the input file will be placed in ordinary symbols output file '. Bss' section. For example:
    . Bss {* (. Bss) * (COMMON)}
Some object file formats have more than one common symbols. For example, MIPS ELF object file format distinguishes standard common symbols and small common symbols.
In this case, the connector is common to other types of special symbols using a different section names. In the case of MIPS ELF, the connector
used for the standard normal symbols 'COMMON', and the general use of symbols for the small '. common'.This allows you to put different types of common symbols mapped to
different memory locations.
In some old connection script, you sometimes see '[COMMON]'. This symbol is now obsolete, and it is equivalent to '* (COMMON)'.
Input section and garbage collection 
---------------------------------------
When the connection is garbage collection is in use ('- gc-sections'), which identifies those who should not be excluded section is very useful. This
is achieved by a wildcard in the input section outside the entrance plus' KEEP () 'to achieve, such as' KEEP (* (. init))' or 'KEEP (SORT (*) (. sorts)) '
.
Sample input section 
---------------------
The following example is a complete linker script. It tells the linker to read the file 'all.o' in all sections, and put them in the output section
'outputa' at the beginning of the output section is from the position '0 x10000 'at the beginning. From the file 'foo.o' to all of the sections in '. Input1'
in the same output section closely packed. From the file 'foo.o' to all of the sections in '. Input2' all fit into output section 'outputb' in the back
to keep from 'foo1.o' in the coming festival '. input1'. All files from any remaining '. Input1' and '. Input2' section is written to the output section
'outputc' in.
    SECTIONS {
      outputa 0x10000:
        {
        all.o
        foo.o (. INPUT1)
        }
      outputb:
        {
        foo.o (. INPUT2)
        foo1.o (. INPUT1)
        }
      outputc:
        {
        * (. INPUT1)
        * (. INPUT2)
        }
    }
Data output section
-------------------
You can use the output section command 'BYTE', 'SHORT', 'LONG', 'QUAD', or 'SQUAD' explicitly in the output section contains several bytes of data
each keyword is followed by a round in brackets the value to be stored. Value of the expression is stored in the current value of the location counter at.
'BYTE', 'SHORT', 'LONG'' QUAD' command to store one, two, four, eight bytes. Into the byte, the potentiometer
plus the value of the count is stored in bytes.
For example, the following command will be credited to the contents of a one-byte, followed by four bytes, and its content is the symbol 'addr' value.
    BYTE (1)
    LONG (addr)
When using a 64-bit system, 'QUAD' and 'SQUAD' is the same; they are stored 8 bytes, or a 64-bit value. And if the hardware and software
systems are 32-bit, an expression will be calculated as 32. In this case, 'QUAD' store a 32-bit value, and it is zero-extended
to 64 bits, while 'SQUAD' 32-bit value will sign extended to 64 bits.
If the output destination of the file format has an explicit endianness, which in normal circumstances, the value will be stored in this endianness
when an object file format does not have an explicit endianness, the value will be the first endianness of input target file storage.
Note that these commands only in one section describes the interior to be effective, rather than between them, therefore, the following code will generate an error connector
error message:
    SECTIONS {. Text: {* (. Text)} LONG (1). Data: {* (. Data)}}
And this is valid:
    SECTIONS {. Text: {* (. Text); LONG (1)}. Data: {* (. Data)}}
You may use the 'FILL' command to set the fill pattern for the current section. It is followed by an expression in parentheses. Any section of unspecified memory
area (for example, because the input section alignment requirements caused cracks) will be populated with the value of the expression. A 'FILL' statement to cover
itself in the position defined in section appears behind all memory areas; through the introduction of more 'FILL' statement, you can at different locations in the output section
has a different fill styles.
This example shows how to specify the memory area is not filled with '0 x90 ':
    FILL (0x90909090)
'FILL' command with the output section '= FILLEXP' attributes are similar, but it only affects the section following the 'FILL' command back part, rather than the
entire section. If both are used, and that 'FILL' command takes precedence.
Output section keyword
-----------------------
There are two key as the output section of the form of the command.
`CREATE_OBJECT_SYMBOLS '
This command tells the linker to create an input file for each symbol. The name of the symbol just input the file name is associated.
The section of each symbol is `CREATE_OBJECT_SYMBOLS 'command appears that section.
This command has the a.out object file format specific. It is generally not the object file format for other use.
`CONSTRUCTORS '
when using the a.out object file format when connected to the connector using a set of unusual structures to support the C + + global constructors
and destructors number. When the connection does not support the objectives section proprietary file format, such as ECOFF and XCOFF, the connector will automatically identification C + +
global constructors and destructors name. For these object file format, 'CONSTRUCTORS' command tells the linker to construct
the function information into 'CONSTRUCTORS' command appears that the output section. For other object file format, 'CONSTRUCTORS'
command is ignored.
Symbol `__CTOR_LIST__ 'logo global constructors start, and the symbol` __DTOR_LIST' identity ends. The first in the list
is the entrance WORD number, followed by one in the back of every constructor and destructor address, then to a zero WORD. Compiler
must arrange how to actually run the code. For these object file format, GNU C + + is usually from a `__main 'subroutine calls
the constructor, while the `__main 'call is automatically inserted into the` main' boot code. GNU C + + typically use 'atexit' run
destructors, or directly from the function 'exit' to run.
For like 'COFF' or 'ELF' section name, that support proprietary object file format, GNU C + + will usually global constructors and destructors
function address value into '. ctors' and '. dtors' section. The following code sequence into your linker script to go, it will build
the GNU C + + runtime code would like to see table type.
              __CTOR_LIST__ =.;
              LONG ((__CTOR_END__ - __ CTOR_LIST__) / 4 - 2)
              * (. ctors)
              LONG (0)
              __CTOR_END__ =.;
              __DTOR_LIST__ =.;
              LONG ((__DTOR_END__ - __ DTOR_LIST__) / 4 - 2)
              * (. dtors)
              LONG (0)
              __DTOR_END__ =.;
If you are using GNU C + + support for initialization priority, then it can provide some control of the situation in order to run the constructor function,
you must connect to the constructor sorted to ensure that they are executed in the correct order. When using 'CONSTRUCTORS' command,
replaced by `SORT (CONSTRUCTORS) '. When using '. Ctors' and' dtors' section, use `* (SORT (. Ctors)) 'and
`* (SORT (. dtors)) 'instead of` * (. ctors)' and `* (. dtors ) '.
Normally, the compiler and linker will automatically handle these things, and you do not personally care about these things. However, when you're using
C + +, and write your own connection script, you might want to consider these things.
Output section discarded. 
-------------------------
Connector does not create content that do not contain any output section. This is to cite those that may arise or not present any input file input
section of convenience. For example:
    . Foo {* (. Foo)}
If at least one input file has '. Foo' section in the output file it will create a '. Foo' section
If you use other than an input section description as an output section commands, such as a symbol assignment, then the output section is always
created, even if no matching input sections will be created.
A special output section name `/ DISCARD / 'can be used to discard input sections. Be assigned to any named `/ DISCARD / 'output section of the input
section is not included in the output file.
Output section attribute 
-------------------------
Above, we have demonstrated a complete description of the output section, looks like this:
    SECTION [ADDRESS] [(TYPE)]: [AT (LMA)]
      {
        OUTPUT-SECTION-COMMAND
        OUTPUT-SECTION-COMMAND
        ...
      } [> REGION] [AT> LMA_REGION] [: PHDR: PHDR ...] [ = FILLEXP]
We have introduced SECTION, ADDRESS, and OUTPUT-SECTION-COMMAND. In this section, we will introduce the rest of the section attributes.
Output section type 
...................
Each output section may have a type. Type is a keyword in parentheses, the defined types are as follows:
`NOLOAD '
This section should be iconic Ju can not load, so when the program is run, it will not be loaded into memory.
DSECT `'
`COPY '
`INFO '
`OVERLAY '
support for these types of names only for backwards compatibility, they are rarely used. They all have the same effect: This section should be iconic Ju not
be assigned, so when the program is running, there is no memory allocated for this section.
Connector typically mapped to the output section based on the input section to set the output section of the property. You can use the section type to reset this attribute,
for example, in the following script example, 'ROM' section is addressed at memory address zero point, and does not need to be loaded when the program is running.
'ROM' section of the content appears correctly in the connection output file.
    SECTIONS {
      ROM 0 (NOLOAD): {...}
      ...
    }
Output section LMA 
..................
Each section has a virtual address (VMA) and a load address (LMA); appear in the output section describes the settings in the address expression VMS
Connectors usually set to be equal LMA with VMA. You can use the 'AT' key to change this. With the keyword 'AT' behind the expression
LMA designated section load address. Or, `AT> LMA_REGION 'expressions, you can specify a section load address memory area.
This feature is to facilitate the establishment of the ROM image and design. For example, the following connection script creates three output sections: one called '. Text'
from address '0 x1000 'at the beginning, one called'. mdata ', despite its VMA is '0 x2000', it will be loaded into ' . text 'section behind the
rear one is called '. bss' is used to place uninitialized data, and its address from '0 x3000' at the beginning.Symbol '_data' is defined as a value
'0 x2000 ', which represents the value of the location counter value VMA instead LMA.
    SECTIONS
      {
      . text 0x1000: {* (. text) _etext =.;}
      . mdata 0x2000:
        AT (ADDR (. text) + SIZEOF (. text))
        {_data =.; * (. Data); _edata =.; }
      . BSS 0x3000:
        {_bstart =.; * (. BSS) * (COMMON); _bend =.;}
    }
This connection uses the generated script runtime initialization code will contain something like shown below to the initialization data from ROM
image to its runtime copy the address to go. Note that this section of code is how to make good use of the symbols defined in connection script.
    extern char _etext, _data, _edata, _bstart, _bend;
    char * src = & _etext;
    char * dst = & _data;     / * ROM has Data at End of text; Copy it. * /     while (dst <& _edata) {       * dst + + = * src + +;     }     / * Zero BSS * /     for (dst = & _bstart; dst <& _bend; dst + +)       * dst = 0;
   
Output section area 
.....................
You can use the `> REGION 'is assigned to a section of a previously defined region of memory.
Here's a simple example:
    MEMORY {ROM: ORIGIN = 0x1000, LENGTH = 0x1000}
    SECTIONS {ROM: {* (. text)}> ROM}
Output section Phdr 
...................
You can use the `: PHDR 'assigned to a section of a previously defined block. If a node is assigned one or more segments, it was sub-
sections will be assigned with these segments, unless they are explicitly spent ': PHDR' modifier. You can use the ': NONE' to tell the linker not to section
into any one segment.
Here is a simple example:
    PHDRS {text PT_LOAD;}
    SECTIONS {. text: {* (. text)}: text}
Output section filled 
...................
You can use the '= FILLEXP' set the fill pattern for the entire festival. FILLEXP is an expression. Any output is not specified memory segment
area (for example, because the input section of the alignment of cracks) the value that will be filled. If the fill expression is a simple hexadecimal
value, for example, a '0 x 'began a string of hexadecimal digits, and the tail is not a' k 'or' M ', then an arbitrary sixteen hexadecimal number
word sequence can be used to specify the fill style; leading zeros also becomes part of the style. For all other cases, including an additional brackets
or unary operator '+' is an expression that fill styles lowest four-byte value. In all cases, the value is big-endian.
You can also use commands in the output section 'FILL' command to change the fill value.
Here is a simple example:
    SECTIONS {. text: {* (. text)} = 0x90909090}
Cover description 
-------------------
An overlay description provides a simple description of ways to describe those who want to be as a separate part of the memory image loaded into memory, but have to
run in the same memory address section. At run time, a number of management mechanism will cover the section to be covered copied in or out as needed runtime memory address,
and is mostly handled by a simple memory bits. This approach might be useful, for example, in a particular memory area is faster than the other.
Covered by 'OVERLAY' command description. 'OVERLAY' command in the 'SECTIONS' command to use the same description as the output section.
'OVERLAY' complete syntax for the command is as follows:
    OVERLAY [START]: [NOCROSSREFS] [AT (LDADDR)]
      {
        SECNAME1
          {
            OUTPUT-SECTION-COMMAND
            OUTPUT-SECTION-COMMAND
            ...
          } [: PHDR ...] [= FILL]
        SECNAME2
          {
            OUTPUT-SECTION-COMMAND
            OUTPUT -SECTION-COMMAND
            ...
          } [: PHDR ...] [= FILL]
        ...
      } [> REGION] [: PHDR ...] [= FILL]
In addition to 'OVERLAY' keyword, all of which are optional, each section must have a name (above SECNAME1 and SECNAME2). In
'OVERLAY' structure defined in section with the usual 'SECTIONS' structure defined in section are identical, except for one thing, that is, 'OVERLAY'
does not address the definition with the memory region.
Sections are defined for the same start address. Load address all sections are arranged so that they are in memory from the entire 'OVERLAY' load address to open
the beginning are continuous (as defined in Section ordinary, load address is optional, the default is the start address; starting address is optional, the default
is the current location counter value.)
If you use the keyword `NOCROSSREFS ', and in between there is a reference section, the connector will report an error. Because section runs in the same
address, so a direct reference to another section of the section content is wrong.
For 'OVERLAY' in each section, the connector automatically defines two symbols. Symbol `__load_start_SECNAME 'is defined as the beginning of the section contained
into the address. Symbol `__load_stop_SECNAME 'is defined as the last section load address. SECNAME C does not meet the provisions of any character will
be deleted. C (or assembly language) code may use these symbols in the time necessary to move the overlay code.
The coverage area of ​​the final positioning of the counter value is set to the start address of the area covered plus the maximum length of the section.
Here is an example. Remember that this will only appear in the 'SECTIONS' internal structure.
      OVERLAY 0x1000: AT (0x4000)
      {
        . text0 {o1 / *. O (. text)}
        . text1 {O2 / *. O (. text)}
      }
This code defines '. Text0' and '. Text1', they all start from address 0x1000. '. Text0' will be loaded into the address 0x4000 place, while
'. text1' will be loaded to immediately '. text0' after location. Here's a few symbols will be defined: `__load_start_text0 ',
`__load_stop_text0 ',` __load_start_text1', `__load_stop_text1 '.
Copy '. Text1' to the coverage area of ​​the C code might look like the following:
      load_start_text1 extern char __, __ load_stop_text1;
      memcpy ((char *) 0x1000, & __load_start_text1,
              & __load_stop_text1 - & __load_start_text1);
Note that 'OVERLAY' command only for syntactic convenience, because it does all the things that can be used to replace the more basic commands. The above
example can complete with the following wording effects:
      . Text0 0x1000: AT (0x4000) {o1 / *. O (. Text)}
      __load_start_text0 = LOADADDR (. text0);
      __load_stop_text0 = LOADADDR (. text0) + SIZEOF (. text0);
      . text1 0x1000: AT (0x4000 + SIZEOF (. text0)) {O2 / *. O (. text)}
      __load_start_text1 = LOADADDR (. text1);
      __load_stop_text1 = LOADADDR (. text1) + SIZEOF (. text1);
      . = 0x1000 + MAX (SIZEOF (. text0), SIZEOF (. text1));
 
============
Connectors by default is configured to allow all of the available memory blocks allocated. You can use the 'MEMORY' command to reconfigure the settings.
'MEMORY' command descriptor block of memory on the target platform location and length. You can use it to describe which memory regions can be connected using,
which is to avoid the area of memory used. Then you can put the section assigned to a specific area of memory. Connector memory-based locale section
addresses the area for too full, it will display a warning message. Connectors are available in order to meet the area will not be disturbed while section.
A connection script can contain up to a 'MEMORY' command. However, you can define as many commands arbitrary block of memory, the syntax
is as follows:
    MEMORY
      {
        NAME [(ATTR)]: ORIGIN = ORIGIN, LENGTH = LEN
        ...
      }
NAME is used in the connection memory area referenced in the script's name. A connection script, zone name would be no practical significance. Area name is stored in a
separate namespace, it does not and symbol name, file name, section name conflict, each a memory region must have a unique name.
ATTR string is an optional attribute list, which indicates whether a connection is not in the script explicitly mapped to an input section using a specific
memory area. If you do not specify an input section for some output section, the connector creates an input section with the same name as the output section. If you set
a defined area attribute, the connector will use them to create output for its segment selector memory area.
ATTR string must contain one of the following characters, and must contain only one:
`R '
read-only sections.
`W '
    can be read below.
`X '
executable section.
`A '
can be assigned section.
`I '
is initialized section.
`L '
    with 'I'
`! '
right before an attribute value negated.
If an unmapped section matches the above except '!' Outside of a property, it will be placed in the memory region. '!' Attribute negated the test, so
only if it does not match any properties listed above the line when an unmapped section will be placed into the memory area.
ORIGIN is a place on the starting address of the memory area of expression. In the memory allocation before the execution, the expression must be evaluated to produce a constant,
which means you can not use any Section-related symbols. Keyword 'ORIGIN' can be abbreviated as 'org' or 'o' (but not write to, than
as 'ORG')
LEN is a charge on the long memory area (in bytes) of the expression. Like ORIGIN expression that is assigned before executing it
must be determined as a constant value. Keyword 'LENGTH' can be abbreviated to 'len' or 'l'.
In the following example, we specify the two can be used to allocate memory area: one starting at 0, with 256kb length, and the other from 0x4000000
begin with 4mb length. Connector will be those who do not explicitly mapped and is a read-only or executable sections into 'rom' memory region. And the other will
not explicitly outside mapped to section put into 'ram' memory region.
    MEMORY
      {
        ROM (RX): ORIGIN = 0, LENGTH = 256K
        RAM (! RX): ORG = 0x40000000, L = 4M
      }
Once you have defined a region of memory, you can also instruct the connector to the specified output sections into to this memory area, which can be used
'> REGION' output section attribute. For example, if you have a file called 'mem' area of memory, you can use the output section definition '> mem'. If
fruit is not specified address for an output section, the connector will be set to the address of the memory area to the next available address. If the total is mapped to an
output stage of a memory area is too large for the area, the connector will prompt an error message.
PHDRS command 
=============
ELF object file format using the "Program Header", which is what people known as the "festival." Program header describes how the program should be loaded into memory.
You can use with the '-p' option 'objdump' command to print out the program header.
When you are in a pure ELF ELF program running on the system, the system loader reads the file header is calculated through how to load the file. It
is only in the program header is set correctly circumstances will work properly. This manual does not describe how to interpret the file system loader header details
issues; For more information, see the ELF ABI.
Connection will be in default under shun create yourself an available program header. However, in some cases, you might need to more precisely specify the program header.
You can use the command 'PHDRS' for this purpose. When the connector in the connection script to see 'PHDRS' command, it will create is assigned a
program header.
Connectors ELF output file is generated only when care 'PHDRS' command. In other cases, the connector is simply ignored 'PHDRS'.
Here is 'PHDRS' command syntax. Word 'PHDRS', 'FILEHDR', 'AT' and 'FLAGS' are keywords.
    PHDRS
    {
      NAME TYPE [filehdr] [PHDRS] [AT (ADDRESS)]
            [FLAGS (FLAGS)];
    }
NAME only in connection script 'SECTIONS' command is used when referenced. It will not be placed in the output file. Program header name will be stored in a separate
name space. Each program header must have a unique name.
Certain types of program header file describing the system loader to load into memory from the festival. In connection script, you can load through the output section put
into a segment to specify the content of these segments. You can use the ': PHDR' output section attribute to a section into a particular segment.
That certain sections into a plurality of segments is normal. This implies that only one segment of memory contains another segment. You can reuse ': PHDR', in each
section of a segment should contain this use it once.
If you use ': PHDR' put a section into a plurality of segments, and that the connector is not specified, all the subsequent ': PHDR' section are available for distribution into the same
segment. This is for convenience, because usually a string of consecutive sections will be placed in a separate section. You can use the ': NONE' to override the default segment,
tells the linker not to put any one segment section.
You might use later in the program header type 'FILEHDR' and 'PHDRS' keywords to further describe the contents of paragraph. 'FILEHDR' keyword indicates that the paragraph should
include the ELF file header when. 'PHDRS' keyword indicates that the paragraph should contain an ELF program header itself.
TYPE may be one of the following. Numbers indicate the value of the keyword.
`PT_NULL '(0)
indicates an unused program header.
`PT_LOAD '(1)
indicates that the program header describes a file is loaded from the segment.
`PT_DYNAMIC '(2)
    represents a dynamic linking information can find the segment.
`PT_INTERP '(3)
  represents one can find explanations about the name of the program segment.
`PT_NOTE '(4)
represents a segment exists Remarks.
`PT_SHLIB '(5)
  a reserved program header type is defined, but has not been designated ELF ABI.
`PT_PHDR '(6)
means that a can find the program header segment.
EXPRESSION
a given type of program header value expression. This can be defined using the above type of use.
You can use the 'AT' expression specifies a paragraph should be loaded into memory at a specific address.This is now
used in the output section attribute 'AT' commands are exactly the same. Program header 'AT' command overwrites the output section is
of the.
The connectors generally composed segment based on section to set the segment attributes. You can use the 'FLAGS' keyword to explicitly refer to
a given segment flags. FLAGS value must be an integer value. It is used to set the program header 'p_flags' domains.
This is one of the 'PHDRS' examples. It shows a pure ELF systems in a standard program header settings.
    PHDRS
    {
      headers PT_PHDR PHDRS;
      interp PT_INTERP;
      text PT_LOAD filehdr PHDRS;
      Data PT_LOAD;
      Dynamic PT_DYNAMIC;
    }     SECTIONS     {.= SIZEOF_HEADERS;. interp: {* (. interp)}: text: interp .text: {* (. text) }: text       . rodata: {* (. rodata)} / * defaults to: text * /       ...       . =. + 0x1000; / * Move to a new Page in Memory * /       . Data: {* (. Data) }: Data       . Dynamic: {* (. Dynamic)}: Data: Dynamic       ...     }
   
VERSION command 
===============
When using ELF, the linker supports symbol versions. Symbol version only useful when using shared libraries.Dynamic linker run a
possibility with an earlier version of the shared library linking program, you can use the symbol versions to select a specific version of a function.
You can connect directly to the main script contains a version of the script, or you can connect to an implicit form of the script
version of the script. You can also use the '- version-script' linker option.
'VERSION' command syntax is very simple:
    VERSION {version-script-commands}
The format of the version script commands available in Solaris 2.5 with Sun connector format is exactly the same. Version script defines a version of the
node tree. You can specify the version of the script node name and dependencies. You can specify which symbols are bound to which version of the node
, you can also put a limit specified set of symbols to local scope, so they shared libraries are not globally visible outside of it.
The demo version of the easiest method is to produce a scripting language a few small examples:
    VERS_1.1 {
    global:
    foo1;
    local:
    Old *;
    Original *;
    new *;
    };     VERS_1.2 {     foo2;     } VERS_1.1;     VERS_2.0 {     bar1; bar2;     } VERS_1.2;
   
This example version script defines three version nodes. The first version of the node is defined as 'VERS_1.1' it has no other dependencies.
Scripting the symbol 'foo1' bound to 'VERS_1.1'. It put some limited number of symbols to local scope, so they were
not visible outside of the shared library of; This is accomplished through a wildcard, so any name to 'old', 'original' or
'new' at the beginning of the sign will be matched. Available now in the shell wildcard matching file name the same.
Here, the version script defines a node 'VER_1.2'. This node dependency 'VER_1.1'. Scripting the symbol 'foo2' tied
to a node set 'VERS_1.2'.
Finally, the version script defines node 'VERS_2.0'. This node dependency 'VERS_1.2'. Scripting the symbol 'bar1' and
'bar2' bound to the version node 'VERS_2.0'.
When the connector finds a symbol defined in the library are not bound to a version of the specified node, it will mean that it is not bound to a
fixed base version of the library. You can use the 'global: *;' all unspecified symbols bound to a given version of the section
points.
Version node name does not have any special meaning only to facilitate people to read. Version '2 .0 'can appear in '1 .1' and
'1 .2 'between. However, in the version of the script writing, it would be a confusing way.
If the version of the script, which is a unique version of the node, the node name can be omitted. This version of the script is not assigned to the symbol
any version, just choose which symbols are globally visible and which are not.
    {Global: foo; bar; local: *;};
When you put a program with a version with a symbol of shared library, the program itself to know which version of each symbol is that it needs
to be, and it knows it is connected to each section of the shared library version of the node in which it needs.Thus, at run time, dynamic
state loader can do a quick confirmation, to ensure that your library does provide a connection all the procedures needed to resolve all
versions of dynamic symbol node. In this way, it is possible for each dynamic connector that does not require all external symbols through
a search through each of the symbol reference can be resolved.
Symbol versions on SunOS doing minor version is a very mature recognition method. One was presented to the basic problem is that the external
function when required standard references are bound to the correct version, but not all the time the program starts to be binding. If a
shared library months expired, a required interface may not exist; when a program needs to use this interface, it may
suddenly and unexpectedly fail. With the symbolic version, when a user starts their program, if you want to use shared libraries too old, then
the user will get a warning message.
Sun's version of GNU recognized approach has some extensions. The first is the symbol defined in the source file to a symbol bound to a
version node rather than a version of the script. This is mainly to reduce the workload of database maintenance. You can use something like the following
code to achieve this:
    __asm__ (". symver original_foo, foo@VERS_1.1");
In the C source file. Phrase will function 'original_foo' an alias' foo ', and bound to the version node `VERS_1.1'.
Operators 'local:' can be used to prevent the symbol 'original_foo' be exported. Operator '. Symver' version of the phrase take precedence over
the script.
The second GNU extension is given in a shared library to allow multiple versions of the same function. In this way, you can
not increase the shared library major version number and the right interface to do totally incompatible changes.
To achieve this, you must be in a source file repeatedly used '. Symver' operator. Here is an example:
    __ asm__ (. "symver original_foo, foo @");
    __ asm__ (. "symver old_foo, foo@VERS_1.1");
    __ asm__ (. "symver old_foo1, foo@VERS_1.2");
    __ asm__ (. "symver new_foo, foo @ @ VERS_2.0 ");
In this example, 'foo @' represents the symbol 'foo' refers to the base is not bound to a version of the symbol.This example contains the source
files must define 4 C functions: `original_foo ',` old_foo', `old_foo1 ', and` new_foo'.
When you have more than a given symbol defined, it is necessary to have a way to specify a default version of this symbol for
external references can be found on this version. In this way, you can just declare a symbol of a version as the default version,
otherwise you will have multiple definitions of the same symbol.
If you want to bind a reference to the shared library symbols a specified version, you can easily use an alias (eg,
old_foo), or you can use '. symver' operator to specify the binding to an external specific version of the function.
You can also specify the language versions of the script.
    VERSION extern "lang" {version-script-commands}
Supported 'lang' a 'C', 'C + +' and 'Java'.
Connection script expressions 
=============================
Connect scripting language expression syntax with C expression is entirely consistent. All expressions are evaluated as an integer value. All
expressions have been evaluated with the same width. In the 32-bit system is that it is 32, otherwise it is 64.You can use in an expression and set symbol values.
    
Connector in order to use the expression that defines several built-in functions with special purpose.
Constant
---------
All constants are integer values.
As in C, the connector put to '0 'at the beginning of integers as octal numbers put to '0 x' or '0 X 'beginning as hexadecimal. Connector
to the other as a decimal integer.
In addition, you can use the 'K' and 'M' suffix as a constant unit of measurement, namely '1024 'and '1024 * 1024'. For example, the following three
constants represent the same value.
    _fourk_1 = 4K;
    _fourk_2 = 4096;
    _fourk_3 = 0x1000;
Symbolic names
------------
In addition to references to a symbol name are letters, underscores, or periods and may contain letters, numbers, underscores, periods, and hyphens.
Not being referenced symbol names must not conflict with any keywords. You can specify a number of characters it contains is not fixed with the keyword with the same name or
word but symbolic name must be in double quotes:
    "SECTION" = 9;
    "with a space" = "also with a space" + 10;
Because symbols can contain many non-alphanumeric characters, symbols separated by spaces so it is very safe. For example, 'A-B' is a symbol, and 'A - B'
is an expression for subtraction.
Location counter 
--------------------
A special connector variable "dot" '.' Always contains the current output location counter. Since the '.' Total output section in a reference position, it
can only appear in the 'SECTIONS' command in the expression. '.' Symbol can appear in the expression a universal symbol can appear in any position allowed
home.
Assign a value to '.' Location counter will generate movement. This will produce voids in the output section.Location counter never move forward.
    SECTIONS
    {
      output:
        {
          file1 (. text)
          . =. + 1000;
          file2 (. text)
          . + = 1000;
          file3 (. text)
        } = 0x12345678;
    }
In the previous example, from 'file1' a '. Text' section is positioned in the output section 'output' of the starting position. It followed 1000byte of
voids. Then from 'file2' the '. Text' section, the same is followed 1000byte gap, and finally from the 'file3' the '. Text'
section. Symbol '= 0x12345678' specifies what kind of void fill data.
Note: '.' Actually refers to the current objectives contained in the byte offset from the beginning. Typically, it is the 'SECTIONS' statement, whose starting address
is the address 0, because the '.' can be used as an absolute address. However, if the '.' Is used in a section of the description, it refers to this section from the start at the beginning
of the shift, rather than an absolute address. Thus, such a script in the following:
    SECTIONS
    {
        . = 0x100
        . text: {
          * (. text)
          . = 0x200
        }
        . = 0x500
        . Data: {
          * (. Data)
          . + = 0x600
        }
    }
'. Text' section is assigned starting address 0x100, although in '. Text' input sections do not have enough data to fill this area, but its length
degrees or 0x200bytes. (If too much data, it will generate an error message, because it would try to '.' To move forward). '. Data'
section from the 0x500 at the beginning, and it will have at the end of extra space 0x600.
Operators 
---------
Connectors can identify the standard C arithmetic operators set, and their priority set.
    Priorities set associative operator Remarks
    (Highest)
    1 Left! - ~ (1)
    2 Left * /%
    3 Left + -
    4 Left >> <<
    5 Left ==! => << => =
    6 Left &
    7 Left |
    8 Left &&
    9 Left | |
    10 right?:
    11 right & = + = - = * = / = (2)
    (Lowest)
  Note: (1) prefix operator (2) * Note Assignments ::.
Evaluation 
----------
Connectors are lazy to evaluate the expression. It is only when you really need to seek an expression.
Connector requires some information, such as the first section of the start address value, as well as the starting point and length of the memory area, make any connections at
this time are needed. Connect the connector reads the script, when possible, these values ​​were calculated.
However, other values ​​(such as symbol values) until the memory is allocated only after knowing or needs. This value until the additional information (than
if the output section length) can be used for symbolic assignment was only when calculated.
Until the memory assignment, the length of the section will be known, so the length of the assignment depends on the section only to the memory allocation will be executed after.
Some expressions, such as those dependent on the location counter '.', Must be evaluated in the course of time allocation is calculated.
If the result of an expression is now needed, but now can not get this value, this will cause an error. For example, like below this
kind of a script:
    SECTIONS
      {
        . text 9 + this_isnt_constant:
          {* (. text)}
      }
Will generate an error message 'non constant expression for initial address'.

Expression festival 
----------------------------


When a connector calculate an expression, the result may be an absolute value, may also be associated with a section. A section related 
expression is a section from the base address of the beginning of the partial fixed nominal value.


Expressions in connection script determines its position is absolute or sections relevant. One appears at the output of the expression is defined in section with the output 
section of the base address. A expression in other places is absolute.


If you pass '-r' option specifies the need for re-bit output, it is assigned a section related to the expression for the symbol will be relocatable. Italian 
think is the next operation will change the connection value of this symbol. The festival is a symbolic expression of the section where the relevant section.


Is assigned a sign of the absolute expression further connecting operation of the back will always keep its value constant. Symbol is absolute, and 
does not have any particular relevant section.


If an expression may be related to the festival, you can use the built-in function 'ABSOLUTE' to force an expression is absolute. For example, 
to create an output section is assigned to '. data' at the end of the address of the absolute symbol:


    SECTIONS 
      {
        . Data: {* (. Data) _edata = ABSOLUTE (.);}
      }
If you do not use 'ABSOLUTE', '_edata' will follow section '. Data' related.

Built-in Functions 
-----------------

In order to use the connection script expression, connection scripting language contains a number of built-in functions.

`ABSOLUTE (EXP) ' 
returns the absolute value of the expression EXP (not relocatable, instead of non-negative). Mainly to an absolute value assigned to a section within the definition of 
useful symbols.


`ADDR (SECTION) ' 
returns the absolute address section SECTION (VMA). Your script must be defined before the address of this section. In the following example 
the, 'symbol_1' and 'symbol_2' is assigned to the same value.


        SECTIONS {... 
          . OUTPUT1: 
            { 
            start_of_output_1 = ABSOLUTE (.); 
            ... 
            } 
          . output: 
            { 
            Symbol_1 = ADDR (. OUTPUT1); 
            symbol_2 = start_of_output_1; 
            } 
        ...}


`ALIGN (EXP) ' 
Return the location counter '.' alignment to the next EXP specified boundary value. 'ALIGN' does not change the value of the location counter, it is only 
in the positioning counter top made ​​an arithmetic operation. Here is an example, it is in front of the section after the output section '. Data' alignment 
to the next '0 x2000 'byte boundary, and in the input section after section of a variable to be aligned to the next '0 x8000' word section of the border.


        SECTIONS {... 
          . Data ALIGN (0x2000): { 
            * (. Data) 
            variable = ALIGN (0x8000); 
          } 
        ...}


This case before a 'ALIGN' designated a section location because it is used as defined in section ADDRESS attribute options appear. Section 
two 'ALIGN' is used to define the value of a symbol.

Built-in function 'NEXT' Contact 'ALIGN' very similar.

`BLOCK (EXP) ' 
This is the 'ALIGN' is synonymous with the other in order to remain compatible connector. This is the address to set the output section is useful.


`DATA_SEGMENT_ALIGN (MAXPAGESIZE, COMMONPAGESIZE) ' 
    This is synonymous with the following two expressions: 
        (ALIGN (maxpagesize) + (. & (maxpagesize - 1))) 
    or: 
        (ALIGN (maxpagesize) + (. & (maxpagesize - COMMONPAGESIZE) ))


Implicit connection script 
=======================


If you specify an output file connector, and the connector does not recognize it is an object file or archive file, it will attempt to read it as 
a connection script. If the file can not be analyzed as a connection script, the connector will report an error.

An implicit linker script will not replace the default linker script.
Typically, an implicit linker script contains only a symbol assignment, or 'INPUT', 'GROUP' or 'VERSION' command.

BFD 
***


Connector on the target through the BFD library to manipulate files and archive files. These libraries allow the connector to ignore the use of the target file format associated 
routines to manipulate the target file. Simply create a new BFD back and add it to the library, a different object file formats will be 
supported. But in order to save runtime memory, connectors and related tools are generally configured to support only available target a subset of file formats, 
you can use 'objdump-i' to list you configured all supported formats.


Like most cases, BFD is a conflict with each other in a variety of a compromise between the needs, the impact of a major BFD design because 
factor is efficiency. Because BFD simplifies the procedures and the background, the more time and effort was put in to the pursuit of optimization algorithms faster.


BFD a byproduct of the solution is that you have to remember there is the potential for loss of information.When using BFD mechanism, where there are two useful information may 
be lost: the conversion and during output.

How it works: BFD summary. 
===============================

When a target file is opened, BFD subroutines automatically determine the format of the input object files.They are then used in memory pointer pointing to a subroutine 
to build a descriptor This descriptor is used to access the target file's data structure elements.


Because of the need different information from an object file, BFD from different sections of the file to read them, and processed. For example, a very common connector 
operation is to handle the symbol table. Each one offers a backstage BFD symbolic expression in the target file format specification with internal conversion between formats function 
as a connector requires an object file's symbol table, it calls through a memory pointer one from the corresponding BFD background subroutines, this 
sub-program reads the table and put it into a standardized form. Then, the connector writes the output file symbol table, another BFD back subroutine is called to 
create a new symbol table and put it into a selected output format.

Loss of information.
----------------

In the output process, the information may be lost. BFD supported output formats do not provide consistent feature, and in a certain format that can be 
described in a different format information may be put in no place. An example is the 'b.out' in the alignment information in a 'a.out' format 
file, no place to store alignment information, so when a file is from 'b.out' concatenated and produce a 'a.out' the 
file, alignment information will not be passed to the output file (or in the connector alignment information for internal use, so the connector is still correct execution)


Another example is COFF section names. COFF file can contain an unlimited number of sections, each with a text section name. If the connection destination is 
in an unsupported format section too (for example, 'a.out'), or does not contain a section name format (for example, Oasys format), the connector is not 
as easy to handle as usual it. You can put the desired input and output sections by connecting a scripting language for detailed mapping to solve the next problem.


In the process of normalization information will be lost. BFD internal specifications of the format corresponding to the external form of not exhaustive; some of the input format 
and the structure does not correspond to the internal representation. This means that BFD back in from the outside to the inside or from internal to external conversion process can not 
maintain all possible data.

This limit is only an application to read and write one format to another format it will be a problem. Every one has the responsibility to safeguard the background as BFD 
much data, the internal BFD canonical form has a pair of opaque BFD core structure, export only to the background. When reading a file in one format, the 
canonical format to whom it will generate. Meanwhile, the background of all the information stored may be lost.If these data are then written in the same format to write 
back, you can use BFD daemon provided by the kernel before the election preparations with the same canonical form. Because there is a lot in the background between the same things in 
the big endianCOFF copied into littile endian COFF, or 'a.out' to 'b.out' time, there will be no loss of information. While some hybrid cell 
type are connected together, only those formats with different file formats objective information will be lost.