In GNU Assembler, what does a dot signify at the beginning of a name?
Asked Answered
S

2

15

The following is a line from a microprocessor startup file, intended for input into the GNU assembler as:

.section  .isr_vector,"a",%progbits

Does the dot at the beginning of the name .isr_vector mean anything special? PS: This name is referenced by the GNU linker ld.

EDIT:

This name also shows up in readelf output as a Section Header:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  ...
  [ 1] .isr_vector       PROGBITS        08000000 008000 0001ac 00   A  0   0  1
Shawm answered 29/12, 2013 at 21:49 Comment(2)
It's an assembler directive.Africander
But my understanding is that .section is the directive, but .isr_vector is a name.Shawm
S
21

A dot preceding a name is either an assembler directive or a local label.

An assembler directive tells as to do something special, for example .text tells it to generate data in the text section of the object file (for things like code and literals that cannot be changed). There's also directives like .space which tell it to allocate empty space in the object file, this is often used to allocate space in the bss section.

On the other hand, we have local labels like .L1 that are used in the code but aren't meant to be exported in the object file and should be hidden from the symbol table.

Stouffer answered 29/12, 2013 at 22:14 Comment(3)
+1 Thanks. Just to clarify: in this case, the dot hides the name?Shawm
@Shawm Not necessarily, since it's an argument to the .section directive it's probably a section name just like .text, .data, and .bss. The as documentation clearly leaves open the possibility for named sectionsStouffer
.L docs: sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-NamesRobillard
K
8

However, I don't agree that it is a local variable. Only symbols prefixing .L mean local variables.(The naming convention for local symbol is portable, but some convention is machine-dependent). Type info as, navigate to chapter Symbols and sub-chapter Symbol-names, and you will get it.

I think it is just a symbol, which is the name for a section, and this name is referred in the linker script. You said that you saw this in the microprocessor start-up file. Of course, linking microprocessor start-up files needs linker script. And this name is just used for reference, which may sound weird but is real.

Kathaleenkatharevusa answered 13/3, 2018 at 3:29 Comment(2)
Section names with a period were just a naming convention to separate system sections from user ones in the ELF specifications. Section names with a dot (.) prefix are reserved for the system, although applications may use these sections if their existing meanings are satisfactory. Applications may use names without the prefix to avoid conflicts with system sections. The object file format lets one define sections not in the list above. An object file may have more than one section with the same name.Unwitnessed
@MichaelPetch Thanks! Frankly speaking, I am confused why user-specified section name prefixes with a dot. Now I finally get the official answer.Kathaleenkatharevusa

© 2022 - 2024 — McMap. All rights reserved.