.align 2 in arm-gas

#7074886
Lesenswert?

Ich wundere mich gerade über Folgendes: Ich habe ein paar Daten meinem 
Flash-Image hinzugefügt, ASCII-Bytes, die mit einer 0 terminiert werden.
Ist die Stringlänge gerade, macht die angehängte 0 die nächste Adresse 
für das folgende .hword ungerade, also füge ich ein .align 2 auf jeden 
Fall ein.


Das gibt also folgendes Bild:
1
.hword 0x2da0,0x6f6c ; .byte 105,110,105,116,0; .align 2 @ init
2
.hword 0x2d98,0x6f68 ; .byte 98,111,111,116,97,112,112,63,0; .align 2 @ bootapp?
3
.hword 0x2d90,0x6ef8 ; .byte 46,98,97,110,110,101,114,0; .align 2 @ .banner
4

5
0000af20  3f 34 34 3b 38 74 07 65  2a 2a 3b 2e 35 35 38 08  |?44;8t.e**;.558.|
6
0000af30  2e 33 34 33 04 00 00 00  a0 2d 6c 6f 69 6e 69 74  |.343.....-loinit|
7
0000af40  00 00 00 bf 98 2d 68 6f  62 6f 6f 74 61 70 70 3f  |.....-hobootapp?|
8
0000af50  00 00 00 bf 90 2d f8 6e  2e 62 61 6e 6e 65 72 00  |.....-.n.banner.|
9
0000af60  88 2d f0 6e 56 45 52 53  00 00 00 bf 80 2d 8c 6e  |.-.nVERS.....-.n|

Man sieht z.B., daß "init" (gerade) mit der 0 dann auf einer ungeraden 
Adresse landet. Das anschließende .align 2 fügt aber 3 bytes hinzu 
(einschließlich eines "ominösen" BF - byte fill?)
Warum wird nicht einfach mit einem Byte (0) aufgefüllt, meinetwegen auch 
"BF"?
Moderator Persönliche Seite #7074908
Lesenswert?

https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html

" The way the required alignment is specified varies from system to 
system. For the a29k, hppa, m68k, m88k, w65, sparc, and Hitachi SH, and 
i386 using ELF format, the first expression is the alignment request in 
bytes. For example `.align 8' advances the location counter until it is 
a multiple of 8. If the location counter is already a multiple of 8, no 
change is needed.

For other systems, including the i386 using a.out format, it is the 
number of low-order zero bits the location counter must have after 
advancement. For example `.align 3' advances the location counter until 
it a multiple of 8. If the location counter is already a multiple of 8, 
no change is needed.

This inconsistency is due to the different behaviors of the various 
native assemblers for these systems which GAS must emulate. GAS also 
provides .balign and .p2align directives, described later, which have a 
consistent behavior across all architectures (but are specific to GAS). 
"

Ich vermute, dass das beim ARM ein 2^N ist. Du müsstest also .align 1 
schreiben.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren