Enaud
Enaud

Reputation: 11

Reading a structure of 32bits pointers in a 64bit processor

Passing 32bit pointers in a defined structure to a new ARM 64bit processor

Trying to read from legacy code that uses structure of 32bit pointers created in a 32bit processor in another piece of hardware that is passed in a common memory area with a 64bit processor using 64bit pointers.

struct _32bit_addr_ptr 
{
 unsigned int *addr1;
 unsigned int *addr2;
 unsigned int *addr3;
}test;
test.addr1 = 0x12345678;
test.addr2 = 0x23456781;
test.addr3 = 0x34567812;

So the data would look something like this.
the data block in big endian would look like:

1234 5678 2345 6781 3456 7812  

If I use the same structure in the 64bit pointer it will of course use 8 bytes per address and not give the right results.

Is there a way to define the structure in the 64bit processor in the structure without having to use a structure that does not use pointers and a cast outside of the structure to translate it?

struct _32bit_address
{
 unsigned int addr_value1;
 unsigned int addr_value2;
 unsigned int addr_value3;
}test2;

unsigned long long Addr_ptr = (unsigned long long *)(test2.addr_value1)

Upvotes: 1

Views: 440

Answers (1)

Pointers are meant to be as wide as the addressing area, thus they HAVE TO be 64bit ones in your case.

However, if these structures are generated on the fly by a certain routine, you can try to convert them to offsets to a 64bit base address, either 32bit or better 16bit offsets if the offsets are less than 65536.

You have to modify both the address generator and the ones using these structures for this though.

Anything else is simply impossible.

Either you live with the 64bit pointers or you do quite an amount of modifications all around.

Upvotes: 1

Related Questions