fix: wiznet bloatlib
This commit is contained in:
@@ -59,8 +59,13 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
// DNS protocol constants
|
||||
#define INITRTT 2000L /* Initial smoothed response time */
|
||||
#define MAXCNAME (MAX_DOMAIN_NAME + (MAX_DOMAIN_NAME>>1)) /* Maximum amount of cname recursion */
|
||||
#define DNS_HEADER_LEN 12 /* Length of the DNS header in bytes */
|
||||
#define QTYPE_A 0x0001 /* Query type for IPv4 address resolution (A record) */
|
||||
#define QCLASS_IN 0x0001 /* Class for internet (IN) queries, indicating the DNS class of the query */
|
||||
#define MAX_LABEL_LENGTH 63 /* Maximum length of a DNS label (part of a domain name) in bytes */
|
||||
|
||||
#define TYPE_A 1 /* Host address */
|
||||
#define TYPE_NS 2 /* Name server */
|
||||
@@ -123,20 +128,17 @@ uint32_t dns_1s_tick; // for timout of DNS processing
|
||||
static uint8_t retry_count;
|
||||
|
||||
/* converts uint16_t from network buffer to a host byte order integer. */
|
||||
uint16_t get16(uint8_t * s)
|
||||
uint16_t get16(const uint8_t *s)
|
||||
{
|
||||
uint16_t i;
|
||||
i = *s++ << 8;
|
||||
i = i + *s;
|
||||
return i;
|
||||
return (uint16_t)s[0] << 8 | s[1];
|
||||
}
|
||||
|
||||
/* copies uint16_t to the network buffer with network byte order. */
|
||||
uint8_t * put16(uint8_t * s, uint16_t i)
|
||||
uint8_t *put16(uint8_t *s, uint16_t i)
|
||||
{
|
||||
*s++ = i >> 8;
|
||||
*s++ = i;
|
||||
return s;
|
||||
s[0] = (uint8_t)(i >> 8);
|
||||
s[1] = (uint8_t)(i & 0xFF);
|
||||
return s + 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -332,71 +334,65 @@ uint8_t * dns_answer(uint8_t * msg, uint8_t * cp, uint8_t * ip_from_dns)
|
||||
* 0 - Fail (Timout or parse error)
|
||||
* 1 - Success,
|
||||
*/
|
||||
int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns)
|
||||
int8_t parseDNSMSG(struct dhdr *pdhdr, uint8_t *pbuf, uint8_t *ip_from_dns)
|
||||
{
|
||||
uint16_t tmp;
|
||||
uint16_t i;
|
||||
uint8_t * msg;
|
||||
uint8_t * cp;
|
||||
uint16_t flags;
|
||||
uint8_t *msg = pbuf;
|
||||
uint8_t *cp;
|
||||
|
||||
msg = pbuf;
|
||||
memset(pdhdr, 0, sizeof(*pdhdr));
|
||||
|
||||
pdhdr->id = get16(&msg[0]);
|
||||
tmp = get16(&msg[2]);
|
||||
if (tmp & 0x8000) pdhdr->qr = 1;
|
||||
flags = get16(&msg[2]);
|
||||
|
||||
pdhdr->opcode = (tmp >> 11) & 0xf;
|
||||
pdhdr->qr = (flags & 0x8000) != 0;
|
||||
pdhdr->opcode = (flags >> 11) & 0xF;
|
||||
pdhdr->aa = (flags & 0x0400) != 0;
|
||||
pdhdr->tc = (flags & 0x0200) != 0;
|
||||
pdhdr->rd = (flags & 0x0100) != 0;
|
||||
pdhdr->ra = (flags & 0x0080) != 0;
|
||||
pdhdr->rcode = flags & 0xF;
|
||||
|
||||
if (tmp & 0x0400) pdhdr->aa = 1;
|
||||
if (tmp & 0x0200) pdhdr->tc = 1;
|
||||
if (tmp & 0x0100) pdhdr->rd = 1;
|
||||
if (tmp & 0x0080) pdhdr->ra = 1;
|
||||
|
||||
pdhdr->rcode = tmp & 0xf;
|
||||
pdhdr->qdcount = get16(&msg[4]);
|
||||
pdhdr->ancount = get16(&msg[6]);
|
||||
pdhdr->nscount = get16(&msg[8]);
|
||||
pdhdr->arcount = get16(&msg[10]);
|
||||
|
||||
|
||||
/* Now parse the variable length sections */
|
||||
cp = &msg[12];
|
||||
|
||||
/* Question section */
|
||||
for (i = 0; i < pdhdr->qdcount; i++)
|
||||
{
|
||||
// Question section
|
||||
for (uint16_t i = 0; i < pdhdr->qdcount; i++) {
|
||||
cp = dns_question(msg, cp);
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h");
|
||||
#endif
|
||||
if(!cp) return -1;
|
||||
if (!cp) {
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("Error: Question section parsing failed.\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Answer section */
|
||||
for (i = 0; i < pdhdr->ancount; i++)
|
||||
{
|
||||
// Answer section
|
||||
for (uint16_t i = 0; i < pdhdr->ancount; i++) {
|
||||
cp = dns_answer(msg, cp, ip_from_dns);
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("MAX_DOMAIN_NAME is too small, it should be redfine in dns.h");
|
||||
#endif
|
||||
if(!cp) return -1;
|
||||
if (!cp) {
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("Error: Answer section parsing failed.\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Name server (authority) section */
|
||||
for (i = 0; i < pdhdr->nscount; i++)
|
||||
{
|
||||
;
|
||||
// Name server (authority) section
|
||||
for (uint16_t i = 0; i < pdhdr->nscount; i++) {
|
||||
// Process name server records if needed
|
||||
}
|
||||
|
||||
/* Additional section */
|
||||
for (i = 0; i < pdhdr->arcount; i++)
|
||||
{
|
||||
;
|
||||
// Additional section
|
||||
for (uint16_t i = 0; i < pdhdr->arcount; i++) {
|
||||
// Process additional records if needed
|
||||
}
|
||||
|
||||
if(pdhdr->rcode == 0) return 1; // No error
|
||||
else return 0;
|
||||
return (pdhdr->rcode == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -411,69 +407,71 @@ int8_t parseDNSMSG(struct dhdr * pdhdr, uint8_t * pbuf, uint8_t * ip_from_dns)
|
||||
*/
|
||||
// #pragma GCC push_options
|
||||
// #pragma GCC optimize("O0")
|
||||
int16_t dns_makequery(uint16_t op, char *name, uint8_t *buf, uint16_t len) {
|
||||
uint8_t *cp = buf;
|
||||
char *cp1;
|
||||
char sname[MAXCNAME];
|
||||
char *dname;
|
||||
uint16_t p;
|
||||
uint16_t dlen;
|
||||
|
||||
// Ensuring name fits into sname
|
||||
if (strlen(name) >= MAXCNAME) {
|
||||
// Handle error - name too long
|
||||
int16_t dns_makequery(uint16_t op, const char *name, uint8_t *buf, uint16_t len) {
|
||||
// buffer and length check.
|
||||
if (strlen(name) >= MAXCNAME || len < DNS_HEADER_LEN) {
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("Error: Name too long.\n");
|
||||
printf("Error: Name too long or buffer too small.\n");
|
||||
#endif
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *cp = buf;
|
||||
uint16_t total_length = 0;
|
||||
|
||||
// increment message ID
|
||||
DNS_MSGID++;
|
||||
cp = put16(cp, DNS_MSGID);
|
||||
p = (op << 11) | 0x0100; // Recursion desired
|
||||
cp = put16(cp, p);
|
||||
cp = put16(cp, 1);
|
||||
cp = put16(cp, 0);
|
||||
cp = put16(cp, 0);
|
||||
cp = put16(cp, 0);
|
||||
cp = put16(cp, (op << 11) | 0x0100); // flags with recursion desired
|
||||
cp = put16(cp, 1); // questions count
|
||||
cp = put16(cp, 0); // answer RRs
|
||||
cp = put16(cp, 0); // authority RRs
|
||||
cp = put16(cp, 0); // additional RRs
|
||||
total_length += DNS_HEADER_LEN;
|
||||
|
||||
strcpy(sname, name);
|
||||
dname = sname;
|
||||
dlen = strlen(dname);
|
||||
const char* ptr = name;
|
||||
while (*ptr) {
|
||||
const char* dot = strchr(ptr, '.');
|
||||
uint16_t label_len = dot ? (dot - ptr) : (int)strlen(ptr);
|
||||
|
||||
for (;;) {
|
||||
cp1 = strchr(dname, '.'); // Look for next dot
|
||||
uint16_t component_len = cp1 != NULL ? cp1 - dname : dlen;
|
||||
|
||||
*cp++ = component_len; // Write length of component
|
||||
if (component_len == 0) break; // Handle empty component
|
||||
|
||||
memcpy(cp, dname, component_len); // Copy component up to (but not including) dot
|
||||
cp += component_len;
|
||||
|
||||
if (cp1 == NULL) {
|
||||
*cp++ = 0; // Last one; write null terminator
|
||||
break;
|
||||
}
|
||||
|
||||
dname += component_len + 1; // Move past current component and dot
|
||||
dlen -= component_len + 1;
|
||||
|
||||
// Ensures dlen is still valid
|
||||
if (dlen <= 0) {
|
||||
// check label length and buffer capacity
|
||||
if (label_len > MAX_LABEL_LENGTH || total_length + label_len + 2 > len) {
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("Error: dlen is non-positive.\n");
|
||||
printf("Error: Domain part too long or buffer too small.\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
*cp++ = (uint8_t)label_len;
|
||||
memcpy(cp, ptr, label_len);
|
||||
cp += label_len;
|
||||
total_length += label_len + 1;
|
||||
|
||||
// move past current label
|
||||
ptr += label_len;
|
||||
if (*ptr == '.') {
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
cp = put16(cp, 0x0001); // type
|
||||
cp = put16(cp, 0x0001); // class
|
||||
// null terminate the domain name section
|
||||
*cp++ = 0;
|
||||
total_length++;
|
||||
|
||||
return (int16_t)((uint32_t)(cp) - (uint32_t)(buf));
|
||||
// add QTYPE and QCLASS to the buffer
|
||||
if (total_length + 4 > len) {
|
||||
#ifdef _DNS_DEBUG_
|
||||
printf("Error: Buffer too small for QTYPE and QCLASS.\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
cp = put16(cp, QTYPE_A); // QTYPE for A record
|
||||
cp = put16(cp, QCLASS_IN); // QCLASS for IN (Internet)
|
||||
total_length += 4;
|
||||
|
||||
return total_length;
|
||||
}
|
||||
// #pragma GCC pop_options
|
||||
|
||||
/*
|
||||
* CHECK DNS TIMEOUT
|
||||
|
||||
@@ -60,7 +60,7 @@ extern "C" {
|
||||
* @brief Define it for Debug & Monitor DNS processing.
|
||||
* @note If defined, it dependens on <stdio.h>
|
||||
*/
|
||||
// #define _DNS_DEBUG_
|
||||
#define _DNS_DEBUG_
|
||||
|
||||
#define MAX_DNS_BUF_SIZE 256 ///< maximum size of DNS buffer. */
|
||||
/*
|
||||
|
||||
79
notes/memcpy_Os.S
Normal file
79
notes/memcpy_Os.S
Normal file
@@ -0,0 +1,79 @@
|
||||
Dump of assembler code for function dns_makequery:
|
||||
=> 0x00001cfa <+0>: jal t0,0x1b6 <__riscv_save_7>
|
||||
0x00001cfe <+4>: addi sp,sp,-192
|
||||
0x00001d00 <+6>: mv s0,a0
|
||||
0x00001d02 <+8>: mv s1,a1
|
||||
0x00001d04 <+10>: mv s5,a2
|
||||
0x00001d06 <+12>: lhu a5,-1984(gp)
|
||||
0x00001d0a <+16>: addi a5,a5,1
|
||||
0x00001d0c <+18>: slli a5,a5,0x10
|
||||
0x00001d0e <+20>: srli a5,a5,0x10
|
||||
0x00001d10 <+22>: sh a5,-1984(gp)
|
||||
0x00001d14 <+26>: lhu a1,-1984(gp)
|
||||
0x00001d18 <+30>: mv a0,a2
|
||||
0x00001d1a <+32>: jal 0x6a4 <put16>
|
||||
0x00001d1e <+36>: slli s0,s0,0xb
|
||||
0x00001d20 <+38>: ori s0,s0,256
|
||||
0x00001d24 <+42>: slli s0,s0,0x10
|
||||
0x00001d26 <+44>: srai s0,s0,0x10
|
||||
0x00001d28 <+46>: slli a1,s0,0x10
|
||||
0x00001d2c <+50>: srli a1,a1,0x10
|
||||
0x00001d2e <+52>: jal 0x6a4 <put16>
|
||||
0x00001d32 <+56>: li a1,1
|
||||
0x00001d34 <+58>: jal 0x6a4 <put16>
|
||||
0x00001d38 <+62>: li a1,0
|
||||
0x00001d3a <+64>: jal 0x6a4 <put16>
|
||||
0x00001d3e <+68>: li a1,0
|
||||
0x00001d40 <+70>: jal 0x6a4 <put16>
|
||||
0x00001d44 <+74>: li a1,0
|
||||
0x00001d46 <+76>: jal 0x6a4 <put16>
|
||||
0x00001d4a <+80>: mv s4,a0
|
||||
0x00001d4c <+82>: mv s3,sp
|
||||
0x00001d4e <+84>: mv a1,s1
|
||||
0x00001d50 <+86>: mv a0,sp
|
||||
0x00001d52 <+88>: jal 0x1ca8 <strcpy>
|
||||
0x00001d54 <+90>: mv a0,sp
|
||||
0x00001d56 <+92>: jal 0x18e2 <strlen>
|
||||
0x00001d5a <+96>: slli s1,a0,0x10
|
||||
0x00001d5e <+100>: srli s1,s1,0x10
|
||||
0x00001d60 <+102>: j 0x1d90 <dns_makequery+150>
|
||||
0x00001d62 <+104>: mv s0,s1
|
||||
0x00001d64 <+106>: addi s6,s4,1
|
||||
0x00001d68 <+110>: sb s0,0(s4)
|
||||
0x00001d6c <+114>: beqz s0,0x1dae <dns_makequery+180>
|
||||
0x00001d6e <+116>: mv a2,s0
|
||||
0x00001d70 <+118>: mv a1,s3
|
||||
0x00001d72 <+120>: mv a0,s6
|
||||
0x00001d74 <+122>: jal 0x1ce4 <memcpy>
|
||||
0x00001d76 <+124>: add s4,s6,s0
|
||||
0x00001d7a <+128>: beqz s2,0x1da6 <dns_makequery+172>
|
||||
0x00001d7e <+132>: addi a5,s0,1
|
||||
0x00001d82 <+136>: add s3,s3,a5
|
||||
0x00001d84 <+138>: sub s1,s1,s0
|
||||
0x00001d86 <+140>: slli s1,s1,0x10
|
||||
0x00001d88 <+142>: srli s1,s1,0x10
|
||||
0x00001d8a <+144>: addi s1,s1,-1
|
||||
0x00001d8c <+146>: slli s1,s1,0x10
|
||||
0x00001d8e <+148>: srli s1,s1,0x10
|
||||
0x00001d90 <+150>: li a1,46
|
||||
0x00001d94 <+154>: mv a0,s3
|
||||
0x00001d96 <+156>: jal 0x1cba <strchr>
|
||||
0x00001d98 <+158>: mv s2,a0
|
||||
0x00001d9a <+160>: beqz a0,0x1d62 <dns_makequery+104>
|
||||
0x00001d9c <+162>: sub s0,a0,s3
|
||||
0x00001da0 <+166>: slli s0,s0,0x10
|
||||
0x00001da2 <+168>: srli s0,s0,0x10
|
||||
0x00001da4 <+170>: j 0x1d64 <dns_makequery+106>
|
||||
0x00001da6 <+172>: addi s6,s4,1
|
||||
0x00001daa <+176>: sb zero,0(s4)
|
||||
0x00001dae <+180>: li a1,1
|
||||
0x00001db0 <+182>: mv a0,s6
|
||||
0x00001db2 <+184>: jal 0x6a4 <put16>
|
||||
0x00001db6 <+188>: li a1,1
|
||||
0x00001db8 <+190>: jal 0x6a4 <put16>
|
||||
0x00001dbc <+194>: sub a0,a0,s5
|
||||
0x00001dc0 <+198>: slli a0,a0,0x10
|
||||
0x00001dc2 <+200>: srai a0,a0,0x10
|
||||
0x00001dc4 <+202>: addi sp,sp,192
|
||||
0x00001dc6 <+204>: j 0x1ea <__riscv_restore_7>
|
||||
End of assembler dump.
|
||||
138
notes/strcpy_O0.S
Normal file
138
notes/strcpy_O0.S
Normal file
@@ -0,0 +1,138 @@
|
||||
Dump of assembler code for function dns_makequery:
|
||||
=> 0x00000200 <+0>: addi sp,sp,-240
|
||||
0x00000202 <+2>: sw ra,236(sp)
|
||||
0x00000204 <+4>: sw s0,232(sp)
|
||||
0x00000206 <+6>: addi s0,sp,240
|
||||
0x00000208 <+8>: mv a5,a0
|
||||
0x0000020a <+10>: sw a1,-232(s0)
|
||||
0x0000020e <+14>: sw a2,-236(s0)
|
||||
0x00000212 <+18>: mv a4,a3
|
||||
0x00000214 <+20>: sh a5,-226(s0)
|
||||
0x00000218 <+24>: mv a5,a4
|
||||
0x0000021a <+26>: sh a5,-228(s0)
|
||||
0x0000021e <+30>: lw a5,-236(s0)
|
||||
0x00000222 <+34>: sw a5,-20(s0)
|
||||
0x00000226 <+38>: lhu a5,-1984(gp)
|
||||
0x0000022a <+42>: slli a5,a5,0x10
|
||||
0x0000022c <+44>: srli a5,a5,0x10
|
||||
0x0000022e <+46>: addi a5,a5,1
|
||||
0x00000230 <+48>: slli a4,a5,0x10
|
||||
0x00000234 <+52>: srli a4,a4,0x10
|
||||
0x00000236 <+54>: sh a4,-1984(gp)
|
||||
0x0000023a <+58>: lhu a5,-1984(gp)
|
||||
0x0000023e <+62>: slli a5,a5,0x10
|
||||
0x00000240 <+64>: srli a5,a5,0x10
|
||||
0x00000242 <+66>: mv a1,a5
|
||||
0x00000244 <+68>: lw a0,-20(s0)
|
||||
0x00000248 <+72>: jal 0x850 <put16>
|
||||
0x0000024a <+74>: sw a0,-20(s0)
|
||||
0x0000024e <+78>: lh a5,-226(s0)
|
||||
0x00000252 <+82>: slli a5,a5,0xb
|
||||
0x00000254 <+84>: slli a5,a5,0x10
|
||||
0x00000256 <+86>: srai a5,a5,0x10
|
||||
0x00000258 <+88>: ori a5,a5,256
|
||||
0x0000025c <+92>: slli a5,a5,0x10
|
||||
0x0000025e <+94>: srai a5,a5,0x10
|
||||
0x00000260 <+96>: sh a5,-28(s0)
|
||||
0x00000264 <+100>: lhu a5,-28(s0)
|
||||
0x00000268 <+104>: mv a1,a5
|
||||
0x0000026a <+106>: lw a0,-20(s0)
|
||||
0x0000026e <+110>: jal 0x850 <put16>
|
||||
0x00000270 <+112>: sw a0,-20(s0)
|
||||
0x00000274 <+116>: li a1,1
|
||||
0x00000276 <+118>: lw a0,-20(s0)
|
||||
0x0000027a <+122>: jal 0x850 <put16>
|
||||
0x0000027c <+124>: sw a0,-20(s0)
|
||||
0x00000280 <+128>: li a1,0
|
||||
0x00000282 <+130>: lw a0,-20(s0)
|
||||
0x00000286 <+134>: jal 0x850 <put16>
|
||||
0x00000288 <+136>: sw a0,-20(s0)
|
||||
0x0000028c <+140>: li a1,0
|
||||
0x0000028e <+142>: lw a0,-20(s0)
|
||||
0x00000292 <+146>: jal 0x850 <put16>
|
||||
0x00000294 <+148>: sw a0,-20(s0)
|
||||
0x00000298 <+152>: li a1,0
|
||||
0x0000029a <+154>: lw a0,-20(s0)
|
||||
0x0000029e <+158>: jal 0x850 <put16>
|
||||
0x000002a0 <+160>: sw a0,-20(s0)
|
||||
0x000002a4 <+164>: addi a5,s0,-224
|
||||
0x000002a8 <+168>: lw a1,-232(s0)
|
||||
0x000002ac <+172>: mv a0,a5
|
||||
0x000002ae <+174>: jal 0x1ef4 <strcpy>
|
||||
0x000002b2 <+178>: addi a5,s0,-224
|
||||
0x000002b6 <+182>: sw a5,-24(s0)
|
||||
0x000002ba <+186>: lw a0,-24(s0)
|
||||
0x000002be <+190>: jal 0x1b2e <strlen>
|
||||
0x000002c2 <+194>: mv a5,a0
|
||||
0x000002c4 <+196>: sh a5,-26(s0)
|
||||
0x000002c8 <+200>: li a1,46
|
||||
0x000002cc <+204>: lw a0,-24(s0)
|
||||
0x000002d0 <+208>: jal 0x1f1c <strchr>
|
||||
0x000002d4 <+212>: sw a0,-32(s0)
|
||||
0x000002d8 <+216>: lw a5,-32(s0)
|
||||
0x000002dc <+220>: beqz a5,0x2f0 <dns_makequery+240>
|
||||
0x000002de <+222>: lw a4,-32(s0)
|
||||
0x000002e2 <+226>: lw a5,-24(s0)
|
||||
0x000002e6 <+230>: sub a5,a4,a5
|
||||
0x000002ea <+234>: sh a5,-228(s0)
|
||||
0x000002ee <+238>: j 0x2f8 <dns_makequery+248>
|
||||
0x000002f0 <+240>: lhu a5,-26(s0)
|
||||
0x000002f4 <+244>: sh a5,-228(s0)
|
||||
0x000002f8 <+248>: lw a5,-20(s0)
|
||||
0x000002fc <+252>: addi a4,a5,1
|
||||
0x00000300 <+256>: sw a4,-20(s0)
|
||||
0x00000304 <+260>: lhu a4,-228(s0)
|
||||
0x00000308 <+264>: zext.b a4,a4
|
||||
0x0000030c <+268>: sb a4,0(a5)
|
||||
0x00000310 <+272>: lhu a5,-228(s0)
|
||||
0x00000314 <+276>: beqz a5,0x378 <dns_makequery+376>
|
||||
0x00000316 <+278>: lhu a5,-228(s0)
|
||||
0x0000031a <+282>: mv a2,a5
|
||||
0x0000031c <+284>: lw a1,-24(s0)
|
||||
0x00000320 <+288>: lw a0,-20(s0)
|
||||
0x00000324 <+292>: jal 0x1f06 <strncpy>
|
||||
0x00000328 <+296>: lhu a5,-228(s0)
|
||||
0x0000032c <+300>: lw a4,-20(s0)
|
||||
0x00000330 <+304>: add a5,a5,a4
|
||||
0x00000332 <+306>: sw a5,-20(s0)
|
||||
0x00000336 <+310>: lw a5,-32(s0)
|
||||
0x0000033a <+314>: bnez a5,0x34e <dns_makequery+334>
|
||||
0x0000033c <+316>: lw a5,-20(s0)
|
||||
0x00000340 <+320>: addi a4,a5,1
|
||||
0x00000344 <+324>: sw a4,-20(s0)
|
||||
0x00000348 <+328>: sb zero,0(a5)
|
||||
0x0000034c <+332>: j 0x37a <dns_makequery+378>
|
||||
0x0000034e <+334>: lhu a5,-228(s0)
|
||||
0x00000352 <+338>: addi a5,a5,1
|
||||
0x00000354 <+340>: lw a4,-24(s0)
|
||||
0x00000358 <+344>: add a5,a5,a4
|
||||
0x0000035a <+346>: sw a5,-24(s0)
|
||||
0x0000035e <+350>: lhu a5,-26(s0)
|
||||
0x00000362 <+354>: mv a4,a5
|
||||
0x00000364 <+356>: lhu a5,-228(s0)
|
||||
0x00000368 <+360>: sub a5,a4,a5
|
||||
0x0000036c <+364>: slli a5,a5,0x10
|
||||
0x0000036e <+366>: srli a5,a5,0x10
|
||||
0x00000370 <+368>: addi a5,a5,-1
|
||||
0x00000372 <+370>: sh a5,-26(s0)
|
||||
0x00000376 <+374>: j 0x2c8 <dns_makequery+200>
|
||||
0x00000378 <+376>: nop
|
||||
0x0000037a <+378>: li a1,1
|
||||
0x0000037c <+380>: lw a0,-20(s0)
|
||||
0x00000380 <+384>: jal 0x850 <put16>
|
||||
0x00000382 <+386>: sw a0,-20(s0)
|
||||
0x00000386 <+390>: li a1,1
|
||||
0x00000388 <+392>: lw a0,-20(s0)
|
||||
0x0000038c <+396>: jal 0x850 <put16>
|
||||
0x0000038e <+398>: sw a0,-20(s0)
|
||||
0x00000392 <+402>: lw a4,-20(s0)
|
||||
0x00000396 <+406>: lw a5,-236(s0)
|
||||
0x0000039a <+410>: sub a5,a4,a5
|
||||
0x0000039e <+414>: slli a5,a5,0x10
|
||||
0x000003a0 <+416>: srai a5,a5,0x10
|
||||
0x000003a2 <+418>: mv a0,a5
|
||||
0x000003a4 <+420>: lw ra,236(sp)
|
||||
0x000003a6 <+422>: lw s0,232(sp)
|
||||
0x000003a8 <+424>: addi sp,sp,240
|
||||
0x000003aa <+426>: ret
|
||||
End of assembler dump.
|
||||
78
notes/strcpy_Os.s
Normal file
78
notes/strcpy_Os.s
Normal file
@@ -0,0 +1,78 @@
|
||||
Dump of assembler code for function dns_makequery:
|
||||
=> 0x00001cfa <+0>: jal t0,0x1b6 <__riscv_save_7>
|
||||
0x00001cfe <+4>: addi sp,sp,-192
|
||||
0x00001d00 <+6>: mv s0,a0
|
||||
0x00001d02 <+8>: mv s1,a1
|
||||
0x00001d04 <+10>: mv s5,a2
|
||||
0x00001d06 <+12>: lhu a5,-1984(gp)
|
||||
0x00001d0a <+16>: addi a5,a5,1
|
||||
0x00001d0c <+18>: slli a5,a5,0x10
|
||||
0x00001d0e <+20>: srli a5,a5,0x10
|
||||
0x00001d10 <+22>: sh a5,-1984(gp)
|
||||
0x00001d14 <+26>: lhu a1,-1984(gp)
|
||||
0x00001d18 <+30>: mv a0,a2
|
||||
0x00001d1a <+32>: jal 0x6a4 <put16>
|
||||
0x00001d1e <+36>: slli s0,s0,0xb
|
||||
0x00001d20 <+38>: ori s0,s0,256
|
||||
0x00001d24 <+42>: slli s0,s0,0x10
|
||||
0x00001d26 <+44>: srai s0,s0,0x10
|
||||
0x00001d28 <+46>: slli a1,s0,0x10
|
||||
0x00001d2c <+50>: srli a1,a1,0x10
|
||||
0x00001d2e <+52>: jal 0x6a4 <put16>
|
||||
0x00001d32 <+56>: li a1,1
|
||||
0x00001d34 <+58>: jal 0x6a4 <put16>
|
||||
0x00001d38 <+62>: li a1,0
|
||||
0x00001d3a <+64>: jal 0x6a4 <put16>
|
||||
0x00001d3e <+68>: li a1,0
|
||||
0x00001d40 <+70>: jal 0x6a4 <put16>
|
||||
0x00001d44 <+74>: li a1,0
|
||||
0x00001d46 <+76>: jal 0x6a4 <put16>
|
||||
0x00001d4a <+80>: mv s4,a0
|
||||
0x00001d4c <+82>: mv s3,sp
|
||||
0x00001d4e <+84>: mv a1,s1
|
||||
0x00001d50 <+86>: mv a0,sp
|
||||
0x00001d52 <+88>: jal 0x1ca8 <strcpy>
|
||||
0x00001d54 <+90>: mv a0,sp
|
||||
0x00001d56 <+92>: jal 0x18e2 <strlen>
|
||||
0x00001d5a <+96>: slli s1,a0,0x10
|
||||
0x00001d5e <+100>: srli s1,s1,0x10
|
||||
0x00001d60 <+102>: j 0x1d90 <dns_makequery+150>
|
||||
0x00001d62 <+104>: mv s0,s1
|
||||
0x00001d64 <+106>: addi s6,s4,1
|
||||
0x00001d68 <+110>: sb s0,0(s4)
|
||||
0x00001d6c <+114>: beqz s0,0x1dae <dns_makequery+180>
|
||||
0x00001d6e <+116>: mv a2,s0
|
||||
0x00001d70 <+118>: mv a1,s3
|
||||
0x00001d72 <+120>: mv a0,s6
|
||||
0x00001d74 <+122>: jal 0x1cba <strncpy>
|
||||
0x00001d76 <+124>: add s4,s6,s0
|
||||
0x00001d7a <+128>: beqz s2,0x1da6 <dns_makequery+172>
|
||||
0x00001d7e <+132>: addi a5,s0,1
|
||||
0x00001d82 <+136>: add s3,s3,a5
|
||||
0x00001d84 <+138>: sub s1,s1,s0
|
||||
0x00001d86 <+140>: slli s1,s1,0x10
|
||||
0x00001d88 <+142>: srli s1,s1,0x10
|
||||
0x00001d8a <+144>: addi s1,s1,-1
|
||||
0x00001d8c <+146>: slli s1,s1,0x10
|
||||
0x00001d8e <+148>: srli s1,s1,0x10
|
||||
0x00001d90 <+150>: li a1,46
|
||||
0x00001d94 <+154>: mv a0,s3
|
||||
0x00001d96 <+156>: jal 0x1cd0 <strchr>
|
||||
0x00001d98 <+158>: mv s2,a0
|
||||
0x00001d9a <+160>: beqz a0,0x1d62 <dns_makequery+104>
|
||||
0x00001d9c <+162>: sub s0,a0,s3
|
||||
0x00001da0 <+166>: slli s0,s0,0x10
|
||||
0x00001da2 <+168>: srli s0,s0,0x10
|
||||
0x00001da4 <+170>: j 0x1d64 <dns_makequery+106>
|
||||
0x00001da6 <+172>: addi s6,s4,1
|
||||
0x00001daa <+176>: sb zero,0(s4)
|
||||
0x00001dae <+180>: li a1,1
|
||||
0x00001db0 <+182>: mv a0,s6
|
||||
0x00001db2 <+184>: jal 0x6a4 <put16>
|
||||
0x00001db6 <+188>: li a1,1
|
||||
0x00001db8 <+190>: jal 0x6a4 <put16>
|
||||
0x00001dbc <+194>: sub a0,a0,s5
|
||||
0x00001dc0 <+198>: slli a0,a0,0x10
|
||||
0x00001dc2 <+200>: srai a0,a0,0x10
|
||||
0x00001dc4 <+202>: addi sp,sp,192
|
||||
0x00001dc6 <+204>: j 0x1ea <__riscv_restore_7>
|
||||
@@ -18,4 +18,8 @@ board = genericCH32V203C8T6
|
||||
framework = ch32v003fun
|
||||
upload_protocol = wlink # isp, minichlink, wch-link, wlink
|
||||
build_unflags = -march=rv32imacxw
|
||||
build_flags = -march=rv32imac
|
||||
build_flags = -march=rv32imac -Wall -Wextra
|
||||
; dbg
|
||||
; build_type = debug
|
||||
; debug_build_unflags = -Og
|
||||
; debug_build_flags = -Os -ggdb3 -g3
|
||||
|
||||
Reference in New Issue
Block a user