Skip to content

Bug fix in relocation (gas) and add ULP disassembly capability (objdump) #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion binutils/stabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ parse_stab_members (void *dhandle, struct stab_handle *info,
++*pp;
voffset &= 0x7fffffff;

if (**pp == ';' || *pp == '\0')
if (**pp == ';' || **pp == '\0')
{
/* Must be g++ version 1. */
context = DEBUG_TYPE_NULL;
Expand Down
45 changes: 16 additions & 29 deletions gas/config/tc-esp32ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ This is called for every line that contains real assembly code. */
void
md_assemble(char *line)
{
char *toP = 0;
int size, insn_size;
struct esp32ulp_insn *tmp_insn;
char *toP ;
int insn_size;
size_t len;
static size_t buffer_len = 0;
static char *current_inputline;
Expand All @@ -184,47 +183,35 @@ md_assemble(char *line)
current_inputline[len] = ';';
current_inputline[len + 1] = '\0';

//if (insn) //DEBUG_TRACE("dya_pass 222 insn old =%08x\n", (unsigned int)insn->value);
// run the parser on the instruction
// it will return a list of chained "insn",
// the first contains the opcode of the instruction
// and may be followed by other "insn" like an address
state = parse(current_inputline);
//if (insn) //DEBUG_TRACE("dya_pass 222 insn new =%08x\n", (unsigned int)insn->value);
if (state == NO_INSN_GENERATED)
if (state == NO_INSN_GENERATED || !insn)
return;

for (insn_size = 0, tmp_insn = insn; tmp_insn; tmp_insn = tmp_insn->next)
if (!tmp_insn->reloc || !tmp_insn->exp->symbol)
insn_size += 2;
// TODO:DYA insn_size - must be 4 in any case
// add 4 bytes to the fragment code buffer to put the new instruction
// and get buffer pointer (toP) on where to write the instruction
insn_size = 4;
if (insn_size)
toP = frag_more(insn_size);

last_insn_size = insn_size;
toP = frag_more(insn_size);

#ifdef DEBUG
printf("INS: %s\n", line);
#endif
md_number_to_chars(toP, insn->value, insn_size); // put the 4-byte instruction into the current fragment code buffer

while (insn)
{
if (insn->reloc && insn->exp->symbol)
{
size = 4;
//DEBUG_TRACE("insn->reloc && insn->exp->symbol BFD_ARELOC_ESP32ULP_PUSH size =%i, insn->exp->value=%i, insn->pcrel=%i, insn->reloc=%i\n", size, (unsigned int)insn->exp->value, insn->pcrel, insn->reloc);

//char *prev_toP = toP - 2;
//fix_new(frag_now, (prev_toP - frag_now->fr_literal), size, insn->exp->symbol, insn->exp->value, insn->pcrel, insn->reloc);
// were - shift from current word...
fix_new(frag_now, 0, size, insn->exp->symbol, insn->exp->value, insn->pcrel, insn->reloc);
}
else
{
//DEBUG_TRACE("md_number_to_chars insn->value =%08x\n", (unsigned int)insn->value);
//md_number_to_chars(toP, insn->value, 2);
//toP += 2;
// TODO:DYA - this is main changes for 32 bit words!!!!! changes stop work
md_number_to_chars(toP, insn->value, 4);
toP += 4;
// generate a relocation request for this instruction so that linker will put the right address
// toP is the pointer on this instruction in the buffer of the current code fragment
// frag_now->fr_literal is the pointer on the begining of the buffer of the current code fragment
fix_new(frag_now, toP - frag_now->fr_literal, insn_size, insn->exp->symbol, insn->exp->value, insn->pcrel, insn->reloc);
}
size = 4;
#ifdef DEBUG
//DEBUG_TRACE(" reloc : value = %08x, pc=%08x, reloc=%08x BFD_RELOC_ESP32ULP_PLTPC = %08x\n", (unsigned int)insn->value, (unsigned int)insn->pcrel, (unsigned int)insn->reloc, BFD_RELOC_ESP32ULP_PLTPC);
if (insn->exp != ((void*)(0)))
Expand Down
6 changes: 6 additions & 0 deletions opcodes/disassemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#define ARCH_d30v
#define ARCH_dlx
#define ARCH_epiphany
#define ARCH_esp32ulp
#define ARCH_fr30
#define ARCH_frv
#define ARCH_ft32
Expand Down Expand Up @@ -242,6 +243,11 @@ disassembler (bfd *abfd)
disassemble = print_insn_epiphany;
break;
#endif
#ifdef ARCH_esp32ulp
case bfd_arch_esp32ulp:
disassemble = print_insn_esp32ulp;
break;
#endif
#ifdef ARCH_fr30
case bfd_arch_fr30:
disassemble = print_insn_fr30;
Expand Down
Loading