From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mail-a.sr.ht; dkim=pass header.d=maniero.me header.i=@maniero.me Received: from sienna.cherry.relay.mailchannels.net (sienna.cherry.relay.mailchannels.net [23.83.223.165]) by mail-a.sr.ht (Postfix) with ESMTPS id CE5CB200B5 for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 19 Feb 2024 15:06:04 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 06365C2C21 for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 19 Feb 2024 15:06:03 +0000 (UTC) Received: from uk-fast-smtpout2.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 24EF2C1C03 for <~johnnyrichard/olang-devel@lists.sr.ht>; Mon, 19 Feb 2024 15:06:01 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1708355162; a=rsa-sha256; cv=none; b=Hq3++TvhszyteNUF0MgEAi64vijPjX2cm9MqzRkol5m/Y/ACx+zaXDmyIRtnuzacbU//t7 72dYJM0ifGZxOPP1q51vBS+SCJnEYX+5gztxT27X4X09m9lZvN/FYTJSr+Il0NDm8qmKeB svqikju6/N1o52ea4L7rF3P607CIpJm4lv6WozpYNxkm+OWxZXy/F3Ds6Jf2/SVgY6ccog HJzVONG6vq2aqf87Tk2Pt8x0SRtwFKfcK0h1XISks7lYOpzGPdpGdnWwt7aIULm4zosqDs bQwOah2Tok9kgw3T20DULof7jpE6qQF01oDUJoTj+uI/XJxrCgj8H6KxujQymQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1708355162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=4Z18yH5pYtsqbIArmN8dm4ED4g50lRmYluqkzxBXyuI=; b=kdz1sZF3xMSrab09xt36oCFxxLjlN6fC9xCtE0+52hs3AYG+3cdqroPEcWFE0Ge2hFTLg3 fibY3qKqA/rOLpq6oWTNAdf/9XdVCO1AWXG1Lm9dZdLHNHwy8d5lq8rEqaLqdNrs+oicmU s5zzfwP39wGH7ZkARiAmhTJOYGMVtYuVIemlHBOH0G4N2zCjrBiUD0jNHTIFxDY2vExKdi GvW8z5T4AAlh2fRVZecwiQuYYgu7zNRbBcju7osuI5UiCoMWovBqgkkftCbDhm5m7M8KT4 lfEKl5pVT793vF0qK7J3vid5ky0KUjG7oRcjiNSglv4vEkepr39q7bpP3p1n6A== ARC-Authentication-Results: i=1; rspamd-55b4bfd7cb-lzhr8; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Daffy-Abiding: 67e7d1f37eb30f93_1708355162729_2304382889 X-MC-Loop-Signature: 1708355162729:107927182 X-MC-Ingress-Time: 1708355162728 Received: from uk-fast-smtpout2.hostinger.io (uk-fast-smtpout2.hostinger.io [31.220.23.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.113.222.102 (trex/6.9.2); Mon, 19 Feb 2024 15:06:02 +0000 Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1708355156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4Z18yH5pYtsqbIArmN8dm4ED4g50lRmYluqkzxBXyuI=; b=W6Dqx+zq0e3QDekEMToOzAdWIwHd0WgXApq4Wi81cD6zkwm85nzAmSSjMrApnC7pjbnYWS sZZjr5v3Gaj+lHCva4Dzz46BoNrx0QuXq6WpFHPyrJzis9bGpq3RnwHWENFnFcaqniXMQF GvwUF+ywQP4heFaMOOKaB50IL1m4+kYXTrfmvL4TORVHHKb3OuQAIjwRpuiSgGM0Pb9MFP 5Pc2QUkM+3igu/IwggmQ2KXjqiA7k8e+Q2Z8Bw+5xH9HvE0Fxqt3qb2A826U4Kfg0uuPsT y9L51H6al5WPI95JE/2LB30EPLkPNIoeVHMcnn6v82jbLvybgvnf0yiMab8u+w== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 19 Feb 2024 12:05:48 -0300 Message-Id: From: "Carlos Maniero" To: <~johnnyrichard/olang-devel@lists.sr.ht> Subject: [POC] Generating DWARF debugging information X-Mailer: aerc 0.15.2-211-g37d5fc691aff X-CM-Analysis: v=2.4 cv=Rp/DLjmK c=1 sm=1 tr=0 ts=65d36e55 a=5+VMC1FZ3J4mVPAKpPmAqg==:117 a=5+VMC1FZ3J4mVPAKpPmAqg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=BXDaF_L80NYA:10 a=sozttTNsAAAA:8 a=NQRnuSn_rLUi-bslgjUA:9 a=QEXdDO2ut3YA:10 a=su2sCEq6_MYA:10 a=aeg5Gbbo78KNqacMgKqU:22 X-CM-Envelope: MS4xfO/eVqidIdFz2MZMCgyAwTakJHD3iT/1b6rdSrKEuikXInundntpyfZlwc3f0Jagx5hO0thys4GeuPCHnHDzIXybdkh0/VvWxMcagkleRG+2S8nBd7mw NWlA/+UW61eeXT3/FBPiTtzcjPip+zA/+C6qxpX5txTov3zMkLMXlXoUEXR83ZOpfpNcb3u/kzZ8al+lbXrcNNNsVfyrKgHDFSA= X-AuthUser: carlos@maniero.me X-TUID: Tr/K4EyErrC8 Hi everyone. Since it is not that simple to find information about about how to generate debugging information in a way that the program can be debuggable on gdb, I'll dump what I found here. First of all I took the minimal example we have currently in our code base and manually converted it to assembly. Minimal example: fn main(): u32 { return 0 } Correspondent assembly: .text .globl _start _start: call main mov %eax, %edi mov $60, %eax syscall main: nop ; (this nop is mocking a function prelude) mov $32, %eax ret After a few reverse engineer with GCC and C I could be able to make it work with the assembly bellow: .text .globl _start _start: call main mov %eax, %edi mov $60, %eax syscall .file 1 "main_exit.0" main: .loc 1 1 1 nop .loc 1 2 1 mov $32, %eax ret compiling: as main_exit.s -gdwarf-2; ld a.out -o a And that is it.=20 It was really hard to found any documentation of the gnu assembler (gas) directives. So I'm going to document it here: https://software-dl.ti.com/codegen/docs/tiarmclang/rel3_2_0_LTS/gnu_syntax_= arm_asm_language/gnu_arm_directives/debugging_directives.html#gar-debug-dir= ectives That's it!