Trimming merely removes the 00's or FF's that are placed at the end of a rom to make it up to the same size as the memory chip on the cart it came from (on rare occasions (I know of no GBA or DS roms that have this) it is also alternating 00's and FF's but the same applies).
These can almost invariably be deleted, the times where it does not work (the M3 case above and a few NES ones) can usually be made to work by giving a few 00's or FF's back to the rom (the 00/FF's can be used to signify end of line,file,whatever), in this case I usually replace the 00/ff 10 bytes from the start of the rom with a 0C/Fc or something.
For the other sort of trimming whereby you remove/replace sections of a DS rom by breaking it up into the files that make it have not had their saves affected although any instant saves may be affected by it. If you want to know more about this method of trimming roms read the following thread:
http://www.sosuke.com/ezflash/viewtopic.php?t=457
You can almost always save some space with either of these methods.
However a few early intro's on GBA roms contained there code on the end of the rom (same also applies to some translations), some junk appears on the end of a couple of 256mbit GBA roms (USA version Riviera and Mother3 are good examples) and sometimes groups added a release/random date to the end of a rom (Silent hill gba a good example) this all means you will have to remove the intro or manually delete some junk before an automatic trimmer will work.