delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/10/03/02:18:58

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADEF43857C67
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1633241935;
bh=Z9ngHBbrp4WyS8aeC8LTprfHvTt5mOUtEAyhfUjYTNg=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Q8pIk+2DZsWZmqZvgUoUMF01UMQ//Tw0j7KgVH+KHYks7lkvYmPv/1YCFeJsAm63s
ramdzNnaQ6R6a1CpFr19P3yKZNdvDlKt819AjY3mcWzsaBsjWNHailj5herew1RGfm
TaApEK8/yT6JIgkMRtdhhJKiIbAAjuJRZoFZwMeM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D67D03858D3C
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=Z1gvpZgqEUw5dTx3yW99kI1UPdMcVq9gfBmFfw3aqQx5Eywq9sz5LSO+no1kAMU5RnCkFqsNmNp5rU6DJVlY4wJ6mK7461WrQSG5mLUk2U7ROYTbw7kekZqJbXRFVZpYRByJ+cvZo8M0T8gUD/VBiubsl8bRCWR6X8CqYdfDiBk6zDm2Y0iC1KavVdJUqatElUmY7MTiS6fmuqUWBT2qKQClb0ldRzSpay5Zu4wGzNZ6X8Uljs3cqjyxl20QtsU4sKj7QYWmOf3eNs7edTZcCP1hh4j93FTm3j1f7gnipyKW0Fg8IZRpIqmYPc/5gPRkU/GvA+WCy2/i95YleaLoog==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=0+fBjheZ3lsFrnCn52EuSvlce3o/wX4eaC/xWBF5hEk=;
b=nneZ6mcupx//r6XTJnzY2fJl9zAzGb8/P6CxkXpWZa0XhZzsdB+Y6LwzWd1a/QNcpqI4iqmd5LELozdgljEIsuJ/aZGJHQmGn7OBElQQSI7ltsDZBn0QUS4juvYV7vxTRFkYlYm8kJ71NU4OQurljOBBolaeTvw13cfVpNK0uX343YFGRVaLWjDB75d/yVutA0XGsCUL3nNgXpojoHLWj7TLvTb2IyEycZYNWumoUc5D/IwUPVW6MABoJ1WEAnQG4U8pWPlC/eWe8D/vL5sMDilkAHy1DFnBwGqBc4YGK21CB6AdcOnGMUm99lZwE6f5KUWur/QWlHJR0hBS5jacQw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Why can not GNU linker translate relocatable symbol address to
absolute address?
Thread-Topic: Why can not GNU linker translate relocatable symbol address to
absolute address?
Thread-Index: AQHXuBS6kavRcnh/IE+JPdmppk0o2A==
Date: Sun, 3 Oct 2021 06:18:21 +0000
Message-ID: <OSZPR01MB6693C0F97439385103644312BAAD9@OSZPR01MB6693.jpnprd01.prod.outlook.com>
Accept-Language: zh-CN, en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-tmn: [p3RKimH4OdCAB/ymWFiaocJ9jnASI9Pl]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 12080954-4bf4-47f0-9f8c-08d986359966
x-ms-traffictypediagnostic: OSBPR01MB2279:
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: Nxp9J6sS4cXrZnTOAas3Kwo6U0hfHwFPBnK1q9tDBBic+AlMc+9+TwXZKNwh11SAZPUsF6KdRYpnr87XtHGdWBeQC7/fVyAYZ2VqYv5WmQpRrqQplr7ExCwtoPMw/c7q3HA3fOgkAJ6BSGXi5+CbwEnTwJS0W7X0kX2NOAGyzHckKEICx3FL0/zN3gIEP9Ew8lZWSn7epfh1QgdwjmrCc0AOfV9hBMyvP5jXudGhatBFhRtUVjjE+WQv2wQmZtpQp9n10JuIlDCrIeKfdhu8qEVtXdzt11fs+HZXY8Q/6vYDG8Obk0xMDN4JRtDaY8Amn65xLwewZLfGzpS565kxQq+jhO4GJXY35e4E/expfrU25BrYj/KuBfcYX4ZQ1ShYRP9GysvgJK4fX9+wrHJulZ5Gd9bOLDnjtZEb54PYBFG1BZ/59jvSVPlFFMYt9cRg
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: u79KGv0pGAb2CWjWfwwBpm5DGLTbT0PzuIaiwrk9KWPTEhn3Llujet9Cqu/yksJj7ZdNQKxHvclEXrk6qr0uGV/v45BziNR4ZKVoq8ZlY0mBabbyzzVsHpSei25pZTepMyz7QFIggRSm7ZUTkFDU9w==
x-ms-exchange-transport-forked: True
MIME-Version: 1.0
X-OriginatorOrg: outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: OSZPR01MB6693.jpnprd01.prod.outlook.com
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 12080954-4bf4-47f0-9f8c-08d986359966
X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Oct 2021 06:18:21.3429 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSBPR01MB2279
X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_00,
CHARSET_FARAWAY_HEADER, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF,
FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,
SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Level: *
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: =?utf-8?b?5oi0IOW/l+WLhyB2aWEgQ3lnd2lu?= <cygwin AT cygwin DOT com>
Reply-To: =?iso-2022-jp?B?GyRCQlcbKEIgGyRCO1ZNJhsoQg==?= <dzywork AT Outlook DOT com>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Hi:
   I have a problem that the gnu assembler and linker can not relocate symbols address in 16 bit real mode of x86 architecture. Below is the code:



# file: boot.asm

.code16

.text

.global _start

_start:

# initialize

movw %cs, %ax

movw %ax, %ds

movw %ax, %es

movw %ax, %ss

movw $base, %sp



# clear screen

movw $0x0600,  %ax

movw $0x0700,  %bx

movw $0,       %cx

movw $0x184f,  %dx

int $0x10



# set focus

movw $0x200,   %ax

movw $0x0,     %bx

movw $0x0,     %dx

int $0x10



# display on screen: Starting boot

movw $0x1301,  %ax

movw $0x000f,  %bx

movw $0x0,     %dx

movw $msg_len, %cx

pushw %ax

movw %ds,      %ax

movw %ax,      %es

popw %ax

movw msg,      %bp # Assign msg address to %bp, But cannot

                   # translate relocation address to

                   # absolute address. I must use:

                   # movw $msg_addr, %bp

int $0x10



# reset disk

xorb %ah, %ah

xorb %dl, %dl

int $0x13

hlt



msg: .ascii "Starting Boot"

msg_len = . - msg

base = 0x7c00

msg_addr = msg + 0x7c00





.org 510

.word 0xaa55



# file: end


Assembling the file boot.asm in Cygwin shell:
as -o boot.o bootloader5.asm --warn --32 && ld -r -Ttext 0x7c00 -e _start -s -o  boot.tmp boot.o -m i386pe &&  objdump -m i8086  -D boot.tmp


Below is output:

boot.tmp:     file format pe-i386


Disassembly of section .text:

00007c00 <_main>:
    7c00:       8c c8                   mov    %cs,%ax
    7c02:       8e d8                   mov    %ax,%ds
    7c04:       8e c0                   mov    %ax,%es
    7c06:       8e d0                   mov    %ax,%ss
    7c08:       bc 00 7c                mov    $0x7c00,%sp
    7c0b:       b8 00 06                mov    $0x600,%ax
    7c0e:       bb 00 07                mov    $0x700,%bx
    7c11:       b9 00 00                mov    $0x0,%cx
    7c14:       ba 4f 18                mov    $0x184f,%dx
    7c17:       cd 10                   int    $0x10
    7c19:       b8 00 02                mov    $0x200,%ax
    7c1c:       bb 00 00                mov    $0x0,%bx
    7c1f:       ba 00 00                mov    $0x0,%dx
    7c22:       cd 10                   int    $0x10
    7c24:       b8 01 13                mov    $0x1301,%ax
    7c27:       bb 0f 00                mov    $0xf,%bx
    7c2a:       ba 00 00                mov    $0x0,%dx
    7c2d:       b9 0d 00                mov    $0xd,%cx
    7c30:       50                      push   %ax
    7c31:       8c d8                   mov    %ds,%ax
    7c33:       8e c0                   mov    %ax,%es
    7c35:       58                      pop    %ax
    7c36:       8b 2e 43 00             mov    0x43,%bp   # Here is problem: msg address is not absolute address
    7c3a:       cd 10                   int    $0x10
    7c3c:       30 e4                   xor    %ah,%ah
    7c3e:       30 d2                   xor    %dl,%dl
    7c40:       cd 13                   int    $0x13
    7c42:       f4                      hlt
    7c43:       53                      push   %bx
    7c44:       74 61                   je     7ca7 <_main+0xa7>
    7c46:       72 74                   jb     7cbc <_main+0xbc>
    7c48:       69 6e 67 20 42          imul   $0x4220,0x67(%bp),%bp
    7c4d:       6f                      outsw  %ds:(%si),(%dx)
    7c4e:       6f                      outsw  %ds:(%si),(%dx)
    7c4f:       74 00                   je     7c51 <_main+0x51>
        ...
7dfd:       00 55 aa                add    %dl,-0x56(%di)


As you can see, address 0x7c36 is disassembly of: movw msg, %bp. But the absolute address of msg is not 0x7c43. Is there a mistake in my command options ? Thanks!

Best wishes to you!
Zhiyong Dai

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019