patchThe GNU Binary Utilities - Patches: patch #10359, Bugfix: Fix gas ignoring...

 
 

patch #10359: Bugfix: Fix gas ignoring -mbig-endian on RISCV when encoding floats and doubles

Submitter:  None
Submitted:  Wed 14 Jun 2023 12:23:28 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Originator Email:  -email is unavailable-
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 14 Jun 2023 12:23:28 PM UTC, original submission:  

Description:
Related to https://sourceware.org/bugzilla/show_bug.cgi?id=30551

In summary, using the provided Makefile to compile BE and LE versions of the provided test.s, doing objdump then objcopy to strip it to a raw binary and running xxd on both binaries, we can see the following when we perform diff on it:

diff le_test.hex be_test.hex
1c1
< 00000000: 6f00 0000 0000 0000 cdcc 8c3f 0000 0000  o..........?....
---

> 00000000: 6f00 0000 0000 0000 cccd 3f8c 0000 0000  o.........?.....


The upper byte sequence is properly encoded as LE, while the lower byte sequence is not a proper BE encoding: the byte swap only happened at 2 byte boundaries. The proper BE sequence in this case is: 3f 8c cc cd

Changes Made:
Inside gas/config/tc-riscv.c inside function md_atof, ieee_md_atof is called with macro constant TARGET_BYTES_BIG_ENDIAN which is always 0 if not defined otherwise. This ignores -mbig-endian directive. Instead, use a global vairable target_big_endian that is set depending on presence of the -mbig-endian directive.

Testing:
After the above change, building the provided test.s via the provided Makefile and diffing the resulting binaries gives the following:
diff le_test.hex be_test.hex

< 00000000: cdcc8c3f 00000000                    ...?....
---

> 00000000: 3f8ccccd 00000000                    ?.......


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #54831:  Makefile added by None (1KiB - application/octet-stream - Bugfix provided in 0001-Bugfix-Fix-gas-ignoring-mbig-endian-on-RISCV-when-en.patch)
file #54832:  test.s added by None (128B - application/octet-stream - Bugfix provided in 0001-Bugfix-Fix-gas-ignoring-mbig-endian-on-RISCV-when-en.patch)
file #54833:  0001-Bugfix-Fix-gas-ignoring-mbig-endian-on-RISCV-when-en.patch added by None (756B - text/x-patch - Bugfix provided in 0001-Bugfix-Fix-gas-ignoring-mbig-endian-on-RISCV-when-en.patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-06-14 None Attached File- Added Makefile, #54831
        Attached File- Added test.s, #54832
        Attached File- Added 0001-Bugfix-Fix-gas-ignoring-mbig-endian-on-RISCV-when-en.patch, #54833

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code